0% found this document useful (0 votes)
350 views14 pages

(Int Const P 5 Printf ("%D",++ ( P) ) )

The document contains 20 coding questions with multiple choice answers. The questions cover topics like operators, data types, control flow, functions, pointers, and memory management in C programming.

Uploaded by

qwerty6327
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
350 views14 pages

(Int Const P 5 Printf ("%D",++ ( P) ) )

The document contains 20 coding questions with multiple choice answers. The questions cover topics like operators, data types, control flow, functions, pointers, and memory management in C programming.

Uploaded by

qwerty6327
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 14

1. main() { char a[4]="HELLO"; printf("%s",a); } a. b. c. d.

H HELL HELLO Error

2. void main()

{ int const * p=5; printf("%d",++(*p)); }


a. b. c. d. 5 6 Garbage Value Error

3. main()

{ char s[ ]="man"; int i; for(i=0;s[ i ]!=\0;i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }


a. b. c. d. man manmanmanman mmmmaaaannnn Error

4. main()

{ static int var = 5; printf("%d ",var--); if(var) main(); }


a. b. c. d. 555555. Infinite times 543210.infinite times 54321 Error

5. main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++) { printf(" %d ",*p); ++p; } }
a. b. c. d. 2.8 3.4 4 6.7 5 2.8 3.4 4 6.7 5 2.8 2.8 2.8 2.8 . Infinite times 2222223465 Error

6. main() { extern int i; i=20; printf("%d",i); }


a. b. c. d. 20 2 20 20 Error

7. main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }


a. b. c. d. -1 -1 0 2 0 00131 00130 Error

8. main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }


a. b. c. d. 11 12 22 Error

9. main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; } }
a. b. c. d. zero one zero three three Error

10. #include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }t1; struct xx *s; s=&t1; printf("%d",s->x); printf("%s",s->name); }
a. b. c. d. 3 Garbage Value Grabage Value hello 3 hello Error

11. main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }


a. b. c. d. 54554 55555 45545 Error

12. main() { char *p = ayqm; printf(%c,++*(p++)); }


a. b. c. d. a b y Error

13. main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }


a. b. c. d. 22 16 16 16 18 18 18 Error

14. void main() { printf(sizeof (void *) = %d \n, sizeof( void *)); printf(sizeof (int *) = %d \n, sizeof(int *)); printf(sizeof (double *) = %d \n, sizeof(double *)); printf(sizeof(struct unknown *) = %d \n, sizeof(struct unknown *)); }
a. b. c. d. 1111 2222 0281 Error

15. main() {

int i=5; printf(%d,i=++i ==6); }


a. b. c. d. 5 6 1 Error

16. What is the return type of printf() function? a. void b. int c. char d. double 17. struct a { int x ; struct a *b; } a. Nested Structure b. Anonymous Structure c. Self referential Structure d. None of the above. 18 main() { float i=1.5; switch(i) { case 1.5: printf("1"); case 2.5: printf("2"); default : printf("0"); } }
a. b. c. d. 1 12 120 Error

19. main()

{ char not; not=!2; printf("%d",not); }

a. b. c. d.

2 -2 0 1

20. main()

{ int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) { printf("hello"); } else { printf("hi"); } }


a. b. c. d. hello hi hello hi Error

21. #include<stdio.h>

int main(){ int a=0; #if (a==0) printf("Equal"); #else if printf("Not equal"); #endif return 0; }
(A) Equal (B) Not equal (C) Null (D) Garbage (E) Compilation error 22.What will be output if you will execute following c code?

#include<stdio.h> int main(){ for(;NULL;)

printf("cquestionbank"); return 0; }
(A) Cquestionbank (B) bank (C) C (D) Infinite loop (E) blank space

23. What will be output if you will execute following c code?

#include<stdio.h> int main(){ int x=25; if(!!x) printf("%d",!x); else printf("%d",x); return 0; }
(A) 0 (B) 25 (C) 1 (D) -1 (E) 2 24.What will be output if you will execute following c code?

#include<stdio.h> int main(){ float a=0.5, b=0.9; if(a&&b>0.9) printf("Sachin"); else printf("Rahul"); return 0; }
(A) Sachin (B) Rahul (C) null

(D) Run time error (E) Compilation error 25.What will be output if you will execute following c code?

#include<stdio.h> int main(){ int x=5, y=10; if(!(!x) && x) printf("%d",x); else printf("%d",y); return 0 ; }
(A) 1 (B) 0 (C)

(D) 10 (E) Compilation error

26.What will be output if you will execute following c code?

#include<stdio.h> int main(){ char ch=321; printf("%d %c",ch,ch); return 0 ; }


(A) 321 # (B) 65 A (C) 321 ! (D) 66 B (E) Compilation error 27.What will be output if you will execute following c code?

#include<stdio.h> int main(){ int a,b; a = -3- -3; b = -3 - - (-3 ); printf("%d %d",a,b);

return 0 ;

(A) 0 0 (B) 0 -3 (C) -3 0 (D) 0 -6 (E) Compilation error ans 82.What will be output if you will execute following c code?

#include<stdio.h> int main(){ int x; x= -2 + 11 - 7 * 9 % 6 / 12; printf("%d",x); return 0 ; }


(A) 6 (B) 7 (C) 8 (D) 9 (E) Compilation error Ans 29.What will be output if you will execute following c code?

#include<stdio.h> int main(){ int x=3, y=4, z=4; printf("%d", (z>=y>=x?100:200)); } return 0 ;

(A) 100 (B) 200 (C) 0 (D) 1 (E) Compilation error

30.What will be output if you will execute following c code?

#include<stdio.h> int main(){ int a=30, b=40, x; x=(a!=10) && (b=50); printf("%d",x); return 0 ; }
(A) 1 (B)

(C) 3 (D) 4 (E) Compilation error 31.What will be output if you will execute following c code?

#include<stdio.h> int main(){ float x=12.25, y=13.65; if(x=y) printf("x and y are equal"); else printf("x and y are not equal"); return 0 ; } (A) x and y are equal
(B) x and y are not equal (C) It will print nothing (D) Run time error (E) Compilation error 32.What will be output if you will execute following c code?

#include<stdio.h> int main(){ int i=1, j=1; for(;j;printf("%d%d\t",i,j)) j=i++ <= 5; return 0 ; }
(A) 1 2 3 4 5

(B) 11 12 13 14 (C) 21 31 41 51 61 70 (D) Infinite loop (E) Compilation error 33.What function is used to release the allocated memory space? (A) deallocate() (B) release () (C) free () (D) drop() (E) empty ()

34.What will be output if you will execute following c code?

#include<stdio.h> auto int a=5; int main(){ int x; x=~a+a&a+a<<a; printf("%d",x); return 0; }
(A)

(B) 1 (C) 154 (D) 155 (E) Compilation error 35.What will be output if you will execute following c code?

#include<stdio.h> void main(){ int a=5; { int b=10; ++b; ++a; { int a=20; ++a;

} printf(" %d",a);

a=++b; } ++a; ++b; printf("%d %d",a,b);

(A) 7 13 7 (B) 13 13 13 (C) 13 13 5 (D) 6

13 5

(E) Compilation error 36.What will be output if you will execute following c code?

#include<stdio.h> #include<conio.h> void main(){ int a[]={0,1,2,3,4,5,6,7,8,9,10}; int i=0,num; num=a[++i+a[++i]]+a[++i]; printf("%d",num); }
(A) 6 (B) 7 (C) 8 (D) 9 (E) Compilation error 37.What will be output if you will execute following c code?

#include<stdio.h> #include<conio.h> void main(){ int i=3,val; val=sizeof f(i)+ +f(i=1)+ +f(i-1); printf("%d %d",val,i); } int f(int num){ return num*5; }

(A) 2 0 (B) 9 1 (C) 17 0 (D) 2 1 (E) Compilation error

38.What will be output if you will execute following c code?

#include<stdio.h> #include<conio.h> void main(){ int i; (i=8)+=1; printf("%d",i); }


(A) 9 (B) 10 (C) 32 (D) 34 (E) Compilation error 39.What will be output if you will execute following c code?

#include<stdio.h> #include<conio.h> void main(){ char c=-'a'; printf("%d",c); }


(A) 65 (B) -65 (C) -a (D) -97 (E) Compilation error 40.What will be output if you will execute following c code?

#include<stdio.h> int main(){ int num,a=5;

num=-a--; printf("%d }
(A) 5

%d",num,a);

(B) -4 4 (C) -5 4 (D) -4 5 (E) Compilation error

You might also like