C Programming - Online Quiz

Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - What is the output of the below code snippet?
#include<stdio.h>

main() 
{
   for()printf("Hello");
}
A - Infinite loop
B - Prints “Hello” once.
C - No output
D - Compile error
Compiler error, semi colons need to appear though the expressions are optional for the ‘for’ loop. 
Q 2 - What is the output of the following program?
#include<stdio.h>

main()
{ 
   int a[] = {1,2}, *p = a;
   
   printf("%d", p[1]); 
}
A - 1
B - 2
C - Compile error
D - Runtime error
2, as ‘p’ holds the base address then we can access array using ‘p’ just like with ‘a’
Q 3 - Choose the invalid identifier from the below
A - Int
B - volatile
C - DOUBLE
D - __0__
volatile is the reserved keyword and cannot be used an identifier name.
Q 4 - What is the output of the following program?
#include<stdio.h>

main()
{
   char s[] = "Fine";
   *s = 'N';
   
   printf("%s", s);
}
A - Fine
B - Nine
C - Compile error
D - Runtime error
*s=’N’, changes the character at base address to ‘N’.
Q 5 - What is the output of the following program?
#include<stdio.h>

main()
{
   char *s = "Hello";
   
   while(*s!=NULL)
   printf("%c", *s++);
}
A - Hello
B - Helloellolloloo
C - ello
D - Compile error
NULL is equivalent to ‘\0’ in value. Statement *s++ prints the character first and increments the address later.
Q 6 - The C library function rewind() reposition the file pointer at the beginning of the file.
A - True
B - False
void rewind(FILE *stream): In C, the rewind function reposition the file position to the beginning of the file of the given stream. It also erases the error and end-of-file indicators for stream.
Q 7 - In Decimal system you can convert the binary number 1011011111000101 very easily.
A - Yes
B - Hexadecimal system
C - Octal system
D - Both, Octal & Decimal
Hexadecimal is also known as hex or base 16. It is a system help in writing and presenting numerical values. Binary (base 2) is a popular numeral system (represent numbers by just two digit values “0 and 1”), used to present the language of computers. Hexadecimal system can easily convert those numbers.
Q 8 - In DOS, What is the purpose of the function randomize() in Turbo C?
A - Displays a random number generator with a random value based on time
B - Displays a random number 
C - Displays a random number generator in the specified range.
D - Invalid function
 randomize() picks the current time value as the SEED number to generate random numbers.
Q 9 - To print a double value which format specifier can be used?
A - %L
B - %lf
C - %Lf
D - None of the above
Double value can be printed using %lf format specifier.
Q 10 - extern int fun(); - The declaration indicates the presence of a global function defined outside the current module or in another file.
A - True
B - False
 Extern is used to resolve the scope of global identifier.
 Print
 Add Notes
 Bookmark this page