1. What is the percent code for long int?
a. %ld
b. %f
c. %lf
d. %Lf
%ld
2. Which of the following is used to read a char variable 'c' as user input?
a. scanf("%c", c);
b. scanf("%c", &c);
c. Both of the above
d. None of the above
scanf("%c", &c);
3. What is the output of below statement?
printf(5+"HelloWorld");
a. Compile time error
b. Runtime error
c. HelloWorld
d. World
World
4. A variable in C cannot start with
a. A number
b. A special symbol other than underscore
c. Both the above
d. None of the above
Both the above
5. What is the output of the below code?
#include<stdio.h>
Int main()
{
int i = 1, 2, 3;
printf("%d", i);
return 0;
}
a. 1
b. 3
c. Compiler Error
d. Runtime error
Compiler Error
6. What is the output of the below code?
#include<stdio.h>
int main()
{
static int x;
x++;
printf("%d ", x);
return 0;
}
a. Compiler error
b. 1
c. Garbage value
d. 0
1
7. What is the output of the below code?
#include<stdio.h>
#define p 1
int main()
{
printf("%d", p);
#define p 5
printf("%d", p);
}
a. Compiler error
b. Runtime error
c. 1 5
d. 5 5
Compiler error
8. The preprocessor directive #include is required if
a. Console input is used
b. Console output is used
c. Both a and b
d. Neither a nor b
Both a and b
9. Which of the following operator has the highest precedence?
a. *
b. /
c. %
d. ()
()
10. What is the output of the below code?
#include<stdio.h>
#define triple(x) 3*x
int main()
{
int x;
x = 9/ triple(3);
printf("%d", x);
return 0;
}
a. 1
b. 9
c. 0
d. None of the above
9
11. What is the value of k?
int k = 5 - 3 % 2
a. 0
b. 4
c. 2
d. 3
4
12. Which of the following is the correct syntax for multiline comments in C programs?
a. // comments//
b. *
comments
*
c. /
comments
/
d.
/comments
/
/
comments
/
13. What is the output of the below code?
#include <stdio.h>
int main()
{
if (printf("0"))
printf("5");
else
printf("3");
return 0;
}
a. Runtime Error
b. 03
c. 05
d. Compiler error
05
14. What is the output of the below code?
#include <stdio.h>
int p;
int main()
{
if(p)
printf("Hello");
else
printf("World");
return 0;
}
a. Garbage Value
b. Hello
c. World
d. None of the above
World
15. What is the output of the below code?
#include <stdio.h>
int main()
{
int p;
for(p = 11; p != 0; p--)
printf("%d", p--);
return 0;
}
a. 11 9 7 5 3 1
b. 11 10 9 8 7 6 5 4 3 2 1
c. 11 9 7 5 3
d. Infinite loop
Infinite loop
16. What is the output of the below code?
int main()
{
int i=0;
switch (i)
{
case '0': printf("Hello");
break;
case '1': printf("World");
break;
default: printf("HelloWorld");
}
}
a. Hello
b. World
c. HelloWorld
d. All of the above
HelloWorld
1. What is the percent code for long double?
a. %ld
b. %f
c. %lf
d. %Lf
%Lf
2. Which of the following is used to print a char variable 'c' to the console?
a. print("%c", c);
b. printf("%c", c);
c. Both of the above
d. None of the above
printf("%c", c);
3. What does the below statement mean?
scanf("%4s",s);
a. Reads exactly 5 characters from console
b. Reads a maximum of 5 characters from console
c. Reads a minimum of 5 characters from the console
d. None of the above
None of the above
4. What is the output of below statement?
printf("%c", 5[HelloWorld]);
a. Compile time error
b. Runtime error
c. H
d. W
W
5. Variables in C can start with
a. An alphabet
b. Underscore
c. Both of the above
d. None of the above
Both of the above
6. What is the output of the below program
#include<stdio.h>
int main()
{
int i, j=5, k=5;
i = j == k;
printf("%d", i);
return 0;
}
a. 0
b. 5
c. 1
d. Compiler Error
1
7. What is the output of the below code?
#include<stdio.h>
extern int x;
int main()
{
int a,x=32;
a = x++;
printf("%d\t%d ", a,x);
return 0;
}
a. Compiler error
b. 32 33
c. Garbage value
d. 33 33
32 33
8. What is the output of the below code?
#include<stdio.h>
#define ISLESSER(A,B) A < B
int main()
{
#if ISLESSER(A,0)
printf("Hello");
#else
printf("World");
#endif
return 0;
}
a. Hello
b. World
c. Either one of above
d. None of the above
World
9. What is the output of the below code?
#include<stdio.h>
#define p "Hello"
int main()
{
printf("%s", p);
#define p "World"
printf("%s", p);
}
a. Compiler error
b. Runtime error
c. World World
d. Hello World
Compiler error
10. The preprocessor directive #include is used if
a. File input is used
b. File output is used
c. Both a and b
d. Neither a nor b
Both a and b
11. Which of the operator has the highest precedence?
a. +
b. -
c. Both the above
d. None of the above
Both the above
12. What is the output of the below code?
#include<stdio.h>
#define cube(x) x
x
x
int main()
{
int x;
x = 36/ cube(6);
printf("%d", x);
return 0;
}
a. 1
b. 216
c. 36
d. 0
216
13. What is the value of k?
int k = (5 + (9 * 10 % 3)) /2
a. 7
b. 2
c. 3
d. 8
2
14. Which of the following is syntactically incorrect?
a. if(a>3)
b. if(a<3)
c. if(a=3)
d. None of the above
if(a=3)
15. What is the output of the below code?
#include <stdio.h>
int main()
{
if (printf("1"))
printf("2");
else
printf("3");
return 0;
}
a. Runtime Error
b. 13
c. 12
d. Compiler error
12
16. What is the output of the below code?
#include <stdio.h>
int p;
int main()
{
if(p);
else
printf("World");
return 0;
}
a. Garbage Value
b. If block is executed
c. Else block is executed and prints World
d. None of the above
Else block is executed and prints World
17. What is the output of the below code?
#include <stdio.h>
int main()
{
int p;
for(p = 1; p != 11; p++)
printf("%d", p++);
return 0;
}
a. 1 3 5 7 11
b. 12 3 4 5 6 7 8 9 10 11
c. 1 3 5 7
d. Infinite loop
Infinite loop
18. What is the output of the below code?
int main()
{
int i=0;
switch (i)
{
case '0': printf("Hello");
case '1': printf("World");
return;
case 2: printf("Welcome);
default: printf("HelloWorldWelcome");
}
}
a. Hello
b. HelloWorld
c. HelloWorldWelcome
d. H
HelloWorldWelcome