C MCQ Catest1
C MCQ Catest1
4. #include <stdio.h>
int main()
{
int a = 10, b = 20;
if(a=b)
{
printf("Easy"); }
else
{
printf("Hard"); }
return 0;
}
(A) Easy
(B) Hard
(C) EasyHard
(D) Error in program
5. #include <stdio.h>
int main()
{
if(printf("C programming is "))
{
printf("Easy");
}
else
{
printf("Hard");
}
return 0;
}
A) Easy
(B) Hard
(C) C programming is Easy
(D) None of the above
6. #include <stdio.h>
int main()
{
int a = 0;
if(a = printf("How old are you?"))
{
printf(" %d - too young", a);
}
return 0;
}
7. #include<stdio.h>
int main()
{
int k;
k = (1,2,3,4,5);
printf("%d\n", k);
return 0;
}
a) 5
b) 1
c) 2
d) 4
8. #include<stdio.h>
int main()
{
int k;
k = 1,2,3,4,5;
printf("%d\n", k);
return 0;
}
a) 4
b) 1
c) 5
d) 2
a) 5 times
b) 0 times
c) 16 times
d) 15 times
a) compilation error
b) Hello
c) infinite loop
d) none of the above
11. #include<stdio.h>
int main()
{
int x = 10; // integer x
char y = 'a'; // character c
x = x + y;
float z = x + 1.0;
printf("x = %d, z = %f", x, z);
return 0;
}
Output:
12. #include<stdio.h>
int main()
{
double x = 1.2;
// Explicit conversion from double to int
int sum = (int)x + 1;
printf("sum = %d", sum);
return 0;
}
Output:
int main()
{
int i = 1, 2, 3;
printf("%d", i);
return 0;
}
a) 1
b) 3
c) Garbage value
a) 1
b) 3
c) Garbage value
d) Compilation error
int main()
{
int i;
i = 1, 2, 3;
printf("%d", i);
return 0;
}
a) 1
b) 3
c) Garbage value
d) Compile time error
a) a = 0, b = 1, c = 1, d = 0
b) a = 0, b = 0, c = 1, d = 0
c) a = 1, b = 1, c = 1, d = 1
d) a = 0, b = 0, c = 0, d = 0
19. Given that x = 7.5, j = -1.0, n = 1.0, m = 2.0 the value of - - x + j == x>n> = m
is:
a) 0
b) 1
c) 2
d) 3
a) Geeks
b) Quiz
c) GeeksQuiz
d) Compile-time error
22. #include<stdio.h>
int main()
{
int n;
for (n = 9; n!=0; n--)
printf("n = %d", n--);
return 0;
}
a) 1
b) Runtime Error
c) 0
d) Compiler Error
a) 10 times
b) 5 times
c) Infinite times
d) 0 times
29. What will be the final value of c in the following C code snippet? (Initial values:
a = 1, b = 2, c = 1) c += (-c) ? a : b;
a) Syntax Error
b) c = 1
c) c = 2
d) c = 3
a) -2
b) Floating point Exception
c) 1
d) None of the mentioned
main()
{
int x;
printf("%d",scanf("%d",&x)); /* Suppose that input value for scanf is 20 */
34.
# include <stdio.h>
main()
{
int i=0;
for(i=0; i<20; i++)
{
switch(i)
{
case 0: i+=5;
case 1: i+=2;
case 5: i+=5;
default: i+=4;
break;
}
printf("%d ", i);
}
35.
#include <stdio.h>
int main()
{
int c = 5, no = 1000;
do {
no /= c;
} while(c--);