0% found this document useful (0 votes)
40 views15 pages

C Programming Quiz for Developers

The document contains 30 multiple choice questions about C language concepts like operators, precedence, loops, arrays, pointers etc. Each question has 5 options for the output of a given code snippet. The questions test understanding of basic as well as advanced C programming concepts.

Uploaded by

M. Murali
Copyright
© © All Rights Reserved
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)
40 views15 pages

C Programming Quiz for Developers

The document contains 30 multiple choice questions about C language concepts like operators, precedence, loops, arrays, pointers etc. Each question has 5 options for the output of a given code snippet. The questions test understanding of basic as well as advanced C programming concepts.

Uploaded by

M. Murali
Copyright
© © All Rights Reserved
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/ 15

GODB TECH – C TEST 17-09-2015

http://tinyurl.com/oyzlgwy
1. What will be output if you will execute following c code?

#include<stdio.h>

int main(){

int i;

for(i=0;i<5;i++){

int i=10;

printf(" %d",i);

i++;

return 0;

(A) 10 11 12 13 14 (B) 10 10 10 10 10 (C) 0 1 2 3 4 (D) Infinite loop

(E) Compilation error

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

#include<stdio.h>

int main(){

register a,b,x;

scanf("%d %d",&a,&b);

x=a+~b;

printf("%d",x);
return 0;

(A) Output will depend upon user input (B) 0 (C) Output will difference of a and b

(D) Output will addition of a and b (E) Compilation error

3. 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) 5 (B) 0 (C) 1 (D) 153 (E) Compilation error

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

#include<stdio.h>

int main(){

register int a,b;

int c;

scanf("%d%d",&a,&b);

c=~a + ~b + ++a + b++;


printf(" %d",c);

return 0;

//User input is: 1 2

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

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

#include<stdio.h>

int main(){

int arr[3]={10,20,30};

int x=0;

x=++arr[++x]+ ++x+arr[--x];

printf("%d ",x);

return 0;

(A) 23 (B) 43 (C) 22 (D) 44 (E) Compilation error

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

#include<stdio.h>

int main(){

int a[]={10,20,30,40};

int i=3,x;

x=1*a[--i]+2*a[--i]+3*a[--i];
printf("%d",x);

return 0;

(A) 60 (B) 50 (C) 40 (D) 30 (E) Compilation error

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

#include<stdio.h>

int main(){

static int a[][2][3]={0,1,2,3,4,5,6,7,8,9,10,11,12} ;

int i=-1;

int d;

d=a[i++][++i][++i];

printf("%d",d);

return 0;

(A) 9 (B) 10 (C) 11 (D) 12 (E) Compilation error

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

#include<stdio.h>

int main(){

int i=3,val;

val=sizeof (f(i)+ +f(i=1)+ +f(i-1));

printf("%d %d",val,i);
return 0;

int f(int num){

return num*5;

(A) 2 2 (B) 3 3 (C) 2 3 (D) 15 0 (E) Compilation error

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

#include<stdio.h>

int main(){

int x,a=3;

x=+ +a+ + +a+ + +5;

printf("%d %d",x,a);

return 0;

(A) 10 3 (B) 11 3 (C) 10 5 (D) 11 3 (E) Compilation error

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

#include<stdio.h>

int main(){

int num,i=0;

num=-++i+ ++-i;

printf("%d",num);
return 0;

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

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

#include<stdio.h>

int main(){

int num,a=5;

num=-a--+ +++a;

printf("%d %d",num,a);

return 0;

(A) 1 5 (B) -1 6 (C) 1 6 (D) 0 5 (E) Compilation error

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

#include<stdio.h>

int main(){

int num,a=15;

num=- - - -a--;

printf("%d %d",num,a);

return 0;

(A) 15 15 (B) 14 14 (C) 14 15 (D) 15 14 (E) Compilation error


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

#include<stdio.h>

int main(){

int x,a=2;

x=++a,++a,a++;

printf("%d %d",x,a);

return 0;

(A) 5 5 (B) 3 5 (C) 4 5 (D) 5 4 (E) Compilation error

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

#include<stdio.h>

int main(){

int x,i=2;

x=~-!++i;

printf("%d",x);

return 0;

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

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

#include<stdio.h>

int main(){
static double *p,*q,*r,*s,t=5.0;

double **arr[]={&p,&q,&r,&s};

int i;

*p=*q=*r=*s=t;

for(i=0;i<4;i++)

printf("%.0f ",**arr[i]);

return 0;

(A) 5 5 5 5 5 (B) 5 6 7 8 9 (C) 5 4 3 2 1 (D) Infinte loop

(E) Compilation error

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

#include<stdio.h>

int main(){

float x;

x=0.35==3.5/10;

printf("%f",x);

return 0;

(A) 0.000000 (B) 1.000000 (C) 0.350000 (D) 3.500000 (E) Compilation error

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

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

int arr[]={6,12,18,24};

int x=0;

x=arr[1]+(arr[1]=2);

printf("%d",x);

return 0;

(A) 4 (B) 8 (C) 14 (D) 14 (E) Compilation error

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

#include<stdio.h>

int main(){

int a=1,x;

x=sq(++a)+sq(a++)+sq(a++);

printf("%d",x);

return 0;

int sq(int num){

return num*num;

(A) 15 (B) 16 (C) 17 (D) 18 (E) Compilation error

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


#include<stdio.h>

int main(){

printf("%c",*"abcde");

return 0;

(A) acbcd (B) e (C) a (D) null (E) Compilation error

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

#include<stdio.h>

int main(){

printf("%d","abcde"-"abcde");

return 0;

(A) 0 (B) -1 (C) 1 (D) Garbage (E) Compilation error

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

#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) c (B) bank (C) cquestionbank (D) Infinite loop

(E) Compilation error

23. 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) 0 (B) 1 (C) 154 (D) 155 (E) Compilation error

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

#include<stdio.h>

int main(){

int a=5;

int b=10;

++b;

++a;

int a=20;

++a;

a=++b;

++a;

++b;

printf("%d %d",a,b);

printf(" %d",a);

return 0;

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

(E) Compilation error

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

#include<stdio.h>

int 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);

return 0;

(A) 6 (B) 7 (C) 8 (D) 9 (E) Compilation error

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

#include<stdio.h>

int main(){

int i=3,val;

val=sizeof f(i)+ +f(i=1)+ +f(i-1);

printf("%d %d",val,i);

return 0;

int f(int num){

return num*5;
}

(A) 2 0 (B) 7 1 (C) 17 0 (D) 2 1

(E) Compilation error

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

#include<stdio.h>

int main(){

int i;

(i=8)+=1;

printf("%d",i);

return 0;

(A) 9 (B) 10 (C) 32 (D) 34 (E) Compilation error

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

#include<stdio.h>

int main(){

char c=-'a';

printf("%d",c);

return 0;

(A) 65 (B) -65 (C) -a (D) -97 (E) Compilation error


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

#include<stdio.h>

int main(){

int num,a=5;

num=-a--;

printf("%d %d",num,a);

return 0;

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

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

#include<stdio.h>

int main(){

int num,a=10;

num=a&&0+ +-1&&a;

printf("%d %d",num,a);

return 0;

(A) 1 1 (B) 0 0 (C) 1 10 (D) 0 10 (E) Compilation error

You might also like