1. What is the output of below program?
#include<stdio.h>
int main()
{
int i;
for(i = 0,i<5,i++)
{
printf(“Hello”);
}
return 0;
}
(A) Hello is printed 5 times
(B) Compilation Error
(C) Runtime Error
(D) Hello is printed 4 times
Ans: B
2. What is the output of C Program.?
#include<stdio.h>
int main()
{
int k;
for(k=1; k <= 5; k++);
{
printf(“%d “, k);
}
return 0;
}
A) 1 2 3 4 5
B) 1 2 3 4
C) 6
D) 5
Ans: C
3. How many times Hi is printed on console?
#include<stdio.h>
int main()
{
int a = 0;
while(a++)
{
printf(“Hi”);
}
return 0;
}
(A) Nothing is printed on screen
(B) 0 time
(C) 1 time
(D) Infinite times (Until Stack overflow)
Ans:A
4. What will be output of following c code?
#include<stdio.h>
int main()
{
int i=0;
do
{
printf(“%d”,i);
i++;
}while(i<5)
}
(A)0 1 2 3 4
(B)0
(C)0 1 2 3 4 5
(D)Compilation error
Ans: D
5. What is the output of C Program.?
# include<stdio.h>
int main()
{
int a=5;
while(a=123)
{
printf(“HELLO”);
break;
}
printf(“HI”);
return 0;
}
A) HI
B) HELLO
HI
C) HELLO is printed unlimited number of times.
D) Compiler error.
Ans: B
6. What is the output of C Program.?
# include<stdio.h>
int main()
{
int a=5;
while(a >= 3);
{
printf(“HELLO”);
break;
}
printf(“HI”);
return 0;
}
A) HI
B) HELLO
HI
C) HELLO is printed infinite times
D) None of the above
Ans: B
C MCQ Set-10 Explanation
7. What is the output of C Program with functions and pointers.?
int myshow(int *);
int main()
{
int a=10;
myshow(&a);
}
int myshow(int *k)
{
printf(“Received %d, “, *k);
}
A) Received Random Number,
B) Received 10
C) Received 10,
D) Compiler error
Ans:C
8. Which function definition will run correctly?
A. int sum(int a, int b)
return (a + b);
B. int sum(int a, int b)
{
return (a + b);
}
C. int sum(a, b)
return (a + b);
D. Both (a) and (b)
Ans:B
9. Can we use a function as a parameter of another function? [ Eg: void wow(int func()) ]
A. Yes, and we can use the function value conveniently
B. Yes, but we call the function again to get the value, not as convenient as in using variable
C. No, C does not support it.
D.none
Ans:C
C MCQ Set-10 Explanation
10. What is the output of this C code? int foo();
int main()
{
int i = foo();
}
foo()
{
printf(“2 “);
return 2;
}
A. 2
B. Compile time error
C. Depends on the compiler
D. This case is compiler dependent
Ans:A