100% found this document useful (1 vote)
423 views41 pages

C Language Programming

The document contains multiple code snippets in C language and questions about the output of each code snippet when executed. The code snippets cover concepts like switch case statements, operators, loops, macros, constants, variable declarations and more.

Uploaded by

Anshy Singh
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
100% found this document useful (1 vote)
423 views41 pages

C Language Programming

The document contains multiple code snippets in C language and questions about the output of each code snippet when executed. The code snippets cover concepts like switch case statements, operators, loops, macros, constants, variable declarations and more.

Uploaded by

Anshy Singh
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 41

C language

What will be output when you will execute following c code? #include<stdio.h> void main(){ int check=2; switch(check){ case 1: printf("D.W.Steyn"); case 2: printf(" M.G.Johnson"); case 3: printf(" Mohammad Asif"); default: printf(" M.Muralidaran"); } }

Choose all that apply:


(A) (B) (C) (D) (E) M.G.Johnson M.Muralidaran M.G.Johnson Mohammad Asif M.Muralidaran Compilation error None of the above

What will be output when you will execute following c code? #include<stdio.h> void main(){ int check=2; switch(check){ case 1: printf("D.W.Steyn"); case 2: printf(" M.G.Johnson"); case 3: printf(" Mohammad Asif"); default: printf(" M.Muralidaran"); } }

Choose all that apply:


(A) (B) (C) (D) (E) M.G.Johnson M.Muralidaran M.G.Johnson Mohammad Asif M.Muralidaran Compilation error None of the above

What will be output when you will execute following c code? #include<stdio.h> void main(){ int movie=1; switch(movie<<2+movie){ default:printf("3 Idiots"); case 4: printf(" Ghajini"); case 5: printf(" Krrish"); case 8: printf(" Race"); } } Choose all that apply: (A) (B) (C) (D) (E) 3 Idiots Ghajini Krrish Race Race Krrish Ghajini Krrish Race Compilation error

What will be output when you will execute following c code? #include<stdio.h> void main(){ int movie=1; switch(movie<<2+movie){ default:printf("3 Idiots"); case 4: printf(" Ghajini"); case 5: printf(" Krrish"); case 8: printf(" Race"); } } Choose all that apply: (A) (B) (C) (D) (E) 3 Idiots Ghajini Krrish Race Race Krrish Ghajini Krrish Race Compilation error

What will be output when you will execute following c code? #include<stdio.h> void main(){ int const X=0; switch(5/4/3){ case X: printf("Clinton"); break; case X+1:printf("Gandhi"); break; case X+2:printf("Gates"); break; default: printf("Brown"); } }
Choose all that apply: (A) (B) (C) (D) (E) Clinton Gandhi Gates Brown Compilation error

What will be output when you will execute following c code? #include<stdio.h> void main(){ int const X=0; switch(5/4/3){ case X: printf("Clinton"); break; case X+1:printf("Gandhi"); break; case X+2:printf("Gates"); break; default: printf("Brown"); } }
Choose all that apply: (A) (B) (C) (D) (E) Clinton Gandhi Gates Brown Compilation error

What will be output when you will execute following c code? #include<stdio.h> void main(){ switch(5/2*6+3.0){ case 3:printf("David Beckham"); break; case 15:printf("Ronaldinho"); break; case 0:printf("Lionel Messi"); break; default:printf("Ronaldo"); } } Choose all that apply: (A) (B) (C) (D) (E) David Beckham Ronaldinho Lionel Messi Ronaldo Compilation error

What will be output when you will execute following c code? #include<stdio.h> void main(){ switch(5/2*6+3.0){ case 3:printf("David Beckham"); break; case 15:printf("Ronaldinho"); break; case 0:printf("Lionel Messi"); break; default:printf("Ronaldo"); } } Choose all that apply: (A) (B) (C) (D) (E) David Beckham Ronaldinho Lionel Messi Ronaldo Compilation error

What will be output when you will execute following c code? #include<stdio.h> void main(){ int x=-1,y=-1; if(++x=++y) printf("R.T. Ponting"); else printf("C.H. Gayle"); } Choose all that apply: (A) (B) (C) (D) (E) R.T Ponting C.H. Gayle Warning: x and y are assigned a value that is never used Warning: Condition is always true Compilation error

What will be output when you will execute following c code? #include<stdio.h> void main(){ int x=-1,y=-1; if(++x=++y) printf("R.T. Ponting"); else printf("C.H. Gayle"); } Choose all that apply: (A) (B) (C) (D) (E) R.T Ponting C.H. Gayle Warning: x and y are assigned a value that is never used Warning: Condition is always true Compilation error

What will be output when you will execute following c code?

#include<stdio.h> void main(){ int m=5,n=10,q=20; if(q/n*m) printf("William Gates"); else printf(" Warren Buffet"); printf(" Carlos Slim Helu"); }
Choose all that apply: (A) (B) (C) (D) (E) William Gates Warren Buffet Carlos Slim Helu Run time error Compilation error None of the above

What will be output when you will execute following c code?

#include<stdio.h> void main(){ int m=5,n=10,q=20; if(q/n*m) printf("William Gates"); else printf(" Warren Buffet"); printf(" Carlos Slim Helu"); }
Choose all that apply: (A) (B) (C) (D) (E) William Gates Warren Buffet Carlos Slim Helu Run time error Compilation error None of the above

What will be output when you will execute following c code?

#include<stdio.h> void main(){ char arr[11]="The African Queen"; printf("%s",arr); }

Choose all that apply:


(A) (B) (C) (D) (E) The African Queen The The African Compilation error None of the above

What will be output when you will execute following c code?

#include<stdio.h> void main(){ char arr[11]="The African Queen"; printf("%s",arr); }

Choose all that apply:


(A) (B) (C) (D) (E) The African Queen The The African Compilation error None of the above

What will be output when you will execute following c code? #include<stdio.h> void main(){ int xxx[10]={5}; printf("%d %d",xxx[1],xxx[9]); } Choose all that apply: (A) (B) (C) (D) (E) Garbage Garbage 00 null null Compilation error None of the above

What will be output when you will execute following c code? #include<stdio.h> void main(){ int xxx[10]={5}; printf("%d %d",xxx[1],xxx[9]); } Choose all that apply: (A) (B) (C) (D) (E) Garbage Garbage 00 null null Compilation error None of the above

What will be output if you will compile and execute the following c code?

#define x 5+2 void main(){ int i; i=x*x*x; printf("%d",i); } OUTPUT: (A) 343 (B) 27 (C) 133 (D) Compiler error (E) None of above

What will be output if you will compile and execute the following c code?

#define x 5+2 void main(){ int i; i=x*x*x; printf("%d",i); } OUTPUT: (A) 343 (B) 27 (C) 133 (D) Compiler error (E) None of above

What will be output if you will compile and execute the following c code?

void main(){ int i=4,x; x=++i + ++i + ++i; printf("%d",x); } OUTPUT: (A) 21 (B) 18 (C) 12 (D) Compiler error (E) None of above

What will be output if you will compile and execute the following c code?

void main(){ int i=4,x; x=++i + ++i + ++i; printf("%d",x); } OUTPUT: (A) 21 (B) 18 (C) 12 (D) Compiler error (E) None of above

What will be output if you will compile and execute the following c code?

void main(){ int a=10; printf("%d %d %d",a,a++,++a); }

OUTPUT: (A) 12 11 11 (B) 12 10 10 (C) 11 11 12 (D) 10 10 12 (E) Compiler error

What will be output if you will compile and execute the following c code?

void main(){ int a=10; printf("%d %d %d",a,a++,++a); }

OUTPUT: (A) 12 11 11 (B) 12 10 10 (C) 11 11 12 (D) 10 10 12 (E) Compiler error

What will be output if you will compile and execute the following c code?

void main(){ int x; for(x=1;x<=5;x++); printf("%d",x); } OUTPUT: (A) 4 (B) 5 (C) 6 (D) Compiler error (E) None of above

What will be output if you will compile and execute the following c code?

void main(){ int x; for(x=1;x<=5;x++); printf("%d",x); } OUTPUT: (A) 4 (B) 5 (C) 6 (D) Compiler error (E) None of above

What will be output if you will compile and execute the following c code?

#define max 5; void main(){ int i=0; i=max++; printf("%d",i++); }


OUTPUT: (A) 5 (B) 6 (C) 7 (D) 0 (E) Compiler error

What will be output if you will compile and execute the following c code?

#define max 5; void main(){ int i=0; i=max++; printf("%d",i++); }


OUTPUT: (A) 5 (B) 6 (C) 7 (D) 0 (E) Compiler error

What will be output of the following c program? #include<stdio.h> int main(){ long int new=5l; printf("%ld",new); return 0; } OUTPUT:

(A) (B) (C) (D) (E)

5 51 0 Compilation error None of these

What will be output of the following c program? #include<stdio.h> int main(){ long int new=5l; printf("%ld",new); return 0; } OUTPUT:

(A) (B) (C) (D) (E)

5 51 0 Compilation error None of these

What will be output of the following c program? #include<stdio.h> int main(){ long int _=5l; printf("%ld",_); return 0; } OUTPUT: 5 51 0 Compilation error None of these

(A) (B) (C) (D) (E)

What will be output of the following c program? #include<stdio.h> int main(){ long int _=5l; printf("%ld",_); return 0; } OUTPUT: (A) 5 (B) 51 (C) 0 (D) Compilation error (E) None of these

What will be output of the following c program? #include<stdio.h> int main(){ long int a; (float)a=6.5; printf("%f",a); return 0; } OUTPUT: (A) 6.5 (B) 6.500000 (C) 7.000000 (D) Compilation error (E) None of these

What will be output of the following c program? #include<stdio.h> int main(){ long int a; (float)a=6.5; printf("%f",a); return 0; } OUTPUT: (A) 6.5 (B) 6.500000 (C) 7.000000 (D) Compilation error (E) None of these

What will be output of the following c program? #include<stdio.h> int main(){ const a=10; a=~a; printf("%d",a); return 0; }

OUTPUT: (A) 10 (B) -11 (C) 12 (D) Compilation error (E) None of these

What will be output of the following c program? #include<stdio.h> int main(){ const a=10; a=~a; printf("%d",a); return 0; }

OUTPUT: (A) 10 (B) -11 (C) 12 (D) Compilation error (E) None of these

What will be output of the following c program?


main() {s tatic int var = 5; printf("%d ",var--); if(var) main(); } Answer:

What will be output of the following c program?


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

Answer: 54321

#include<stdio.h> main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }

#include<stdio.h> main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } } Answer:Compiler Error: Constant expression required in function main

You might also like