Q1. The output of the code below is Q4.
The output of the code below is
#include <stdio.h> #include <stdio.h>
void main() void main()
{ {
int x =5; int x =5;
if(x <1) if(x <1);
printf("hello"); printf("Hello");
if(x ==5) }
printf("hi"); A. Nothing
else B. Run time error
printf("no"); C. Hello
} D. Varies
A. hi [ANS] c
B. hello Q5. The output of the code below is(When 1
C. no is entered)
D. None of the mentioned #include <stdio.h>
[ANS] a void main()
Q2. The output of the code below is {
#include <stdio.h> char*ch;
int x; printf("enter a value btw 1 to 3:");
void main() scanf("%s",ch);
{ switch(ch)
if(x) {
printf("hi"); case"1": printf("1"); break;
else case"2": printf("2"); break;
printf("how are u"); }
} }
A. hi A. 1
B. how are you B. 2
C. Compile time error C. Compile time error
D. None of the mentioned D. No Compile time error
[ANS] b [ANS] c
Q3. The output of the code below is
#include <stdio.h> Q6. When 1 is entered, The output of the code
void main() below is?
{ #include <stdio.h>
int x =0; void main()
if(x ==0) {
printf("hi"); int ch;
else printf("enter a value btw 1 to 2:");
printf("how are u"); scanf("%d",&ch);
printf("hello"); switch(ch)
} {
A. hi case1: printf("1\n");
B. how are you default: printf("2\n");
C. hello }
D. hihello }
[ANS] d A. 1
B. 2 }
C. 1 2 A. inside if
D. Run time error B. inside else if
[ANS] c C. inside else
Q7. What is the output of this C code? D. Compile time error
#include <stdio.h> [ANS] c
int main() Q10. What is the output of this C code?
{ #include <stdio.h>
int x =1; int main()
if(x >0) {
printf("inside if\n"); int x =0;
elseif(x >0) if(x ==0)
printf("inside elseif\n"); printf("true, ");
} elseif(x =10)
A. inside if printf("false, ");
B. inside elseif printf("%d\n", x);
C. inside if }
inside elseif A. false, 0
D. Compile time error B. true, 0
[ANS] a C. true, 10
Q8. What is the output of this C code? D. Compile time error
#include <stdio.h> [ANS] b
int main() Q11. What is the output of this C code?
{ #include <stdio.h>
int x =0; int main()
if(x++) {
printf("true\n"); int x =0;
else if(x ==1) if(x ==1)
printf("false\n"); if(x >=0)
} printf("true\n");
A. true else
B. false printf("false\n");
C. Compile time error }
D. Undefined behaviour A. true
[ANS] b B. false
C. Depends on the compiler
Q9. What is the output of this C code? D. No print statement
#include <stdio.h> [ANS] d
int main() Q12. What is the output of this C code?
{ #include <stdio.h>
int x =0; int main()
if(x ==1) {
if(x ==0) int a =1;
printf("inside if\n"); if(a--)
else printf("True");
printf("inside else if\n"); if(a++)
else printf("False");
printf("inside else\n"); }
A. True }
B. False A. yes
C. True False B. yes no
D. No Output C. Duplicate case value error
[ANS] a D. Character case value error
Q13. Comment on the output of this C code? [ANS] c
#include <stdio.h> Q16. What is the output of this C code?
int main() #include <stdio.h>
{ int main()
int a =1; {
if(a) float f =1;
printf("All is Well "); switch(f)
printf("I am Well\n"); {
else case1.0:
printf("I am not a River\n"); printf("yes\n");
} break;
A. Output will be All is Well I am Well default:
B. Output will be I am Well I am not a River printf("default\n");
C. Output will be I am Well }
D. Compile time errors during compilation }
[ANS] d A. yes
Q14. What is the output of this C code? B. yes default
#include <stdio.h> C. Undefined behavior
int main() D. Compile time error
{ [ANS] d
int a =1, b =1; Q17. What is the output of this C code?
switch(a) #include <stdio.h>
{ #define max(a) a
case a*b: printf("yes "); int main()
case a-b:printf("no\n"); {
break; int x =1;
} switch(x)
} {
A. yes case max(2):printf("yes\n");
B. no case max(1):printf("no\n");break;
C. Compile time error }
D. yes no }
[ANS] c A. yes no
Q15. What is the output of this C code? B. yes
#include <stdio.h> C. No
int main() D. Compile time error
{ [ANS] c
int x =97; Q18. What is the output of this C code?
switch(x) #include <stdio.h>
{ int main()
case'a':printf("yes ");break; {
case97:printf("no\n");break; switch(printf("Do"))
} {
case1:printf("First\n");break; int a =0, i =0, b;
case2:printf("Second\n");break; for(i =0;i <5; i++)
default:printf("Default\n");break; {
} a++;
} continue;
A. Do }
B. DoFirst }
C. DoSecond A. 2
D. DoDefault B. 3
[ANS] c C. 4
Q19. The following code ‘for(;;)’ represents an D. 5
infinite loop. It can be terminated by. [ANS] d
A. break Q23. What is the output of this C code?
B. exit(0) #include <stdio.h>
C. abort() int main()
D. All of the mentioned {
[ANS] a int a =0, i =0, b;
Q20. What is the output of this C code? for(i =0;i <5; i++)
#include <stdio.h> {
void main() a++;
{ if(i ==3)
double k =0; break;
for(k =0.0; k <3.0; k++) }
printf("Hello"); }
} A. 1
A. Run time error B. 2
B. Hello is printed thrice C. 3
C. Hello is printed twice D. 4
D. Hello is printed infinitely [ANS] d
[ANS] b Q24. The keyword ‘break’ cannot be simply used
Q21. What is the output of this C code? within:
#include <stdio.h> A. do-while
void main() B. if-else
{ C. For
int k; D. While
for(k =-3; k <-5; k++) [ANS] b
printf("Hello"); Q25. What is the output of this C code?
} #include <stdio.h>
A. Hello void main()
B. Infinite hello {
C. Run time error int i =0, j =0;
D. Nothing for(i =0;i <5; i++)
[ANS] d {
for(j =0;j <4; j++)
Q22. What is the output of this C code? {
#include <stdio.h> if(i >1)
int main() break;
{ }
printf("Hi \n"); void main()
} {
} int i =0;
A. Hi is printed 5 times if(i ==0)
B. Hi is printed 9 times {
C. Hi is printed 7 times printf("Hello");
D. Hi is printed 4 times continue;
[ANS] a }
Q26. What is the output of this C code? }
#include <stdio.h> A. Hello is printed infinite times
void main() B. Hello
{ C. Varies
int i =0; D. Compile time error
int j =0; [ANS] d
for(i =0;i <5; i++) Q29. What is the output of this C code?
{ #include <stdio.h>
for(j =0;j <4; j++) void main()
{ {
if(i >1) int i =0;
continue; if(i ==0)
printf("Hi \n"); {
} printf("Hello");
} break;
} }
A. Hi is printed 9 times }
B. Hi is printed 8 times A. Hello is printed infinite times
C. Hi is printed 7 times B. Hello
D. Hi is printed 6 times C. Varies
[ANS] b D. Compile time error
Q27. What is the output of this C code? [ANS] d
#include <stdio.h> Q30. What is the output of this C code?
void main() #include <stdio.h>
{ int main()
int i =0; {
for(i =0;i <5; i++) int i =0;
if(i <4) while(i <2)
{ {
printf("Hello"); if(i ==1)
break; break;
} i++;
} if(i ==1)
A. Hello is printed 5 times continue;
B. Hello is printed 4 times printf("In while loop\n");
C. Hello }
D. Hello is printed 3 times printf("After loop\n");
[ANS] c }
Q28. What is the output of this C code? A. In while loop
#include <stdio.h> After loop
B. After loop do{
C. In while loop i++;
In while loop printf("In while loop\n");
After loop }while(i <3);
D. In while loop }
[ANS] b A. In while loop
Q31. What is the output of this C code? In while loop
#include <stdio.h> In while loop
int main() B. In while loop
{ In while loop
int i =0; C. Depends on the compiler
char c ='a'; D. Compile time error
while(i <2){ [ANS] a
i++; Q34. How many times i value is checked in the
switch(c){ below code?
case'a': #include <stdio.h>
printf("%c ", c); int main()
break; {
break; int i =0;
} do{
} i++;
printf("after loop\n"); printf("in while loop\n");
} }while(i <3);
A. a after loop }
B. aa after loop A. 2
C. after loop B. 3
D. None of the mentioned C. 4
[ANS] b D. 1
Q32. What is the output of this C code? [ANS] b
#include <stdio.h> Q35. How many times i value is checked in the
int main() below code?
{ #include <stdio.h>
do int main()
printf("In while loop "); {
while(0); int i =0;
printf("After loop\n"); while(i <3)
} i++;
A. In while loop printf("In while loop\n");
B. In while loop }
after loop A. 2
C. After loop B. 3
D. Infinite loop C. 4
[ANS] b D. 1
Q33. What is the output of this C code? [ANS] c
#include <stdio.h> Q36. What is the output of this C code?
int main() #include <stdio.h>
{ void main()
int i =0; {
int i =0; int*p = f();
while(++i) printf("%d\n",*p);
{ }
printf("H"); int*f()
} {
} int*j =(int*)malloc(sizeof(int));
A. H *j =10;
B. H is printed infinite times return j;
C. Compile time error }
D. Varies A. 10
[ANS] b B. Compile time error
Q37. What is the output of this C code? C. Segmentation fault/runtime crash since
#include <stdio.h> pointer to local variable is returned
void main() D. Undefined behaviour
{ [ANS] a
int i =0; Q40. Comment on the following pointer
do declaration?
{ int *ptr, p;
printf("Hello"); A. ptr is a pointer to integer, p is not
}while(i !=0); B. ptr and p, both are pointers to integer
} C. ptr is a pointer to integer, p may or may
A. Nothing not be
B. H is printed infinite times D. ptr and p both are not pointers to
C. Hello integer
D. Run time error [ANS] a
[ANS] c Q41. What is the output of this C code?
Q38. What is the output of this C code? #include <stdio.h>
#include <stdio.h> int main()
int main() {
{ int*ptr, a =10;
int i =0, j =0; ptr=&a;
while(i <5, j <10) *ptr+=1;
{ printf("%d,%d/n",*ptr, a);
i++; }
j++; A. 10,10
} B. 10,11
printf("%d, %d\n", i, j); C. 11,10
} D. 11,11
A. 5, 5 [ANS] d
B. 5, 10 Q42. What is the output of this C code?
C. 10, 10 #include <stdio.h>
D. syntax error int x =0;
[ANS] c void main()
Q39. What is the output of this C code? {
#include <stdio.h> int*const ptr=&x;
int*f(); printf("%p\n",ptr);
int main() ptr++;
{ v cf2q21printf("%p\n ",ptr);
} {
A. 0 1 char*s="hello";
B. Compile time error char*p = s;
C. 0xbfd605e8 0xbfd605ec printf("%c\t%c",*(p +3), s[1]);
D. 0xbfd605e8 0xbfd605e8 }
[ANS] b A. h e
Q43. What is the output of this C code? B. l l
#include <stdio.h> C. l o
void main() D. l e
{ [ANS] d
int x =0; Q47. What is the output of this C code?
int*ptr=&5; #include <stdio.h>
printf("%p\n",ptr); void main()
} {
A. 5 char*s="hello";
B. Address of 5 char*p = s;
C. Nothing printf("%c\t%c",1[p], s[1]);
D. Compile time error }
[ANS] d A. h h
Q44. What is the output of this C code? B. Run time error
#include <stdio.h> C. l l
void main() D. e e
{ [ANS] d
int x =0; Q48. What is the output of the code given below?
int*ptr=&x; #include <stdio.h>
printf("%d\n",*ptr); void foo(int[]);
} int main()
A. Address of x {
B. Junk value int ary[4]={1,2,3,4};
C. 0 foo(ary);
D. Run time error printf("%d ",ary[0]);
[ANS] c
Q45. What is the output of this C code? void foo(int p[4])
#include <stdio.h> {
void main() int i =10;
{ p =&i;
char*s="hello"; printf("%d ", p[0]);
char*p = s; }
printf("%c\t%c", p[0], s[1]); A. 10 10
} B. Compile time error
A. Run time error C. 10 1
B. h h D. Undefined behaviour
C. h e [ANS] c
D. h l Q49. What is the output of the code given below?
[ANS] c #include <stdio.h>
Q46. What is the output of this C code? int main()
#include <stdio.h> {
void main() int ary[4]={1,2,3,4};
int*p =ary+3; int p[4];
printf("%d\n", p[-2]); p =ary;
} printf("%d\n", p[1]);
A. 1 }
B. 2 A. 1
C. Compile time error B. Compile time error
D. Some garbage value C. Undefined behavior
[ANS] b D. 2
Q50. What is the output of this C code? [ANS] b
#include <stdio.h> Q54. What is the output of this C code?
int main() #include <stdio.h>
{ int main()
int ary[4]={1,2,3,4}; {
printf("%d\n",*ary); int i =97,*p =&i;
} foo(&i);
A. 1 printf("%d ",*p);
B. Compile time error }
C. Some garbage value void foo(int*p)
D. Undefined variable {
[ANS] a int j =2;
Q51. What is the output of this C code? p =&j;
#include <stdio.h> printf("%d ",*p);
int main() }
{ A. 2 97
const int ary[4]={1,2,3,4}; B. 2 2
int*p; C. Compile time error
p =ary+3; D. Segmentation fault/code crash
*p =5; [ANS] a
printf("%d\n",ary[3]); Q55. What is the output of this C code?
} #include <stdio.h>
A. 4 int main()
B. 5 {
C. Compile time error int i =97,*p =&i;
D. 3 foo(&p);
[ANS] b printf("%d ",*p);
Q52. An array of similar data types which return0;
themselves are collection of dissimilar data }
type are void foo(int**p)
A. Linked Lists {
B. Trees int j =2;
C. Array of Structure *p =&j;
D. All of the mentioned printf("%d ",**p);
[ANS] c }
Q53. What is the output of the code given below? A. 2 2
#include <stdio.h> B. 2 97
int main() C. Undefined behavior
{ D. Segmentation fault/code crash
int ary[4]={1,2,3,4}; [ANS] a
Q56. Which of the following can never be sent by [ANS] b
call-by-value? Q60. What is the output of this C code?
A. Variable #include <stdio.h>
B. Array void m(int p,int q)
C. Structures {
D. Both (b) and (c) int temp = p;
[ANS] b p = q;
Q57. Arguments that take input by user before q = temp;
running a program are called? }
A. main function arguments void main()
B. main arguments {
C. Command-Line arguments int a =6, b =5;
D. Parameterized arguments m(a, b);
[ANS] c printf("%d %d\n", a, b);
Q58. What is the output of this C code? }
#include <stdio.h> A. 5 6
void m(int*p,int*q) B. 5 5
{ C. 6 5
int temp =*p;*p =*q;*q = temp; D. 6 6
} [ANS] c
void main() Q61. What is the output of this C code?
{ #include <stdio.h>
int a =6, b =5; void main()
m(&a,&b); {
printf("%d %d\n", a, b); int k =5;
} int*p =&k;
A. 5 6 int**m =&p;
B. 6 5 printf("%d%d%d\n", k,*p,**m);
C. 5 5 }
D. 6 6 A. 5 5 5
[ANS] a B. 5 5 junk value
Q59. What is the output of this C code? C. 5 junk junk
#include <stdio.h> D. Run time error
void m(int*p) [ANS] a
{ Q62. What is the output of this C code?
int i =0; #include <stdio.h>
for(i =0;i <5; i++) void main()
printf("%d\t", p[i]); {
} int k =5;
void main() int*p =&k;
{ int**m =&p;
int a[5]={6,5,3}; **m =6;
m(&a); printf("%d\n", k);
} }
A. 0 0 0 0 0 A. 5
B. 6 5 3 0 0 B. Compile time error
C. Run time error C. 6
D. 6 5 3 junk junk D. Junk
[ANS] c