Sample Question Set For Coding and Debugging 1.What will be the output of the following statements? int i = 1,j; int i = 1,j; j=i--- -2; printf("%d",j); a) error b) 2 c) 3 d) -3 2. What will be the output of the following statements? int a[2][2] = 3,2,5,4 ; printf("%d",*(*(*(a)))); a) error b) 3 c) garbage value d) 2 3. int const *p=5; printf("%d",++(*p)); what is the output? a) 6 b) 5 c) Compile error d) Run time error 4.main() printf("\nab"); printf("\bsi"); printf("\rha"); 1
what is the output? a) has b)hasaiaab c)hai d)aas 5. #define a 10 main() #define a 50 printf(%d",a); a) 10 b) 50 c) error d) none 6. Which of the following gives the memory address of a variable pointed to by pointer a? A. a; B. *a; C. &a; D. address(a); 7. Which of the following accesses a variable in structure b? A. b->var; B. b.var; C. b-var; D. b>var; 8. What wil be the output of the foll program int a=320; char *ptr; ptr=(char *)&a; printf("%d",*ptr); 2
a)2 b)320 c)64 d)compilation error e)none of the above Because,the binary equivalent of 320 is stored. But the pointer takes only the 8 bits. So the decimal equivalent is 64. 9.what is the output of the following program #include<string.h> char *ptr1=null; char *ptr2=0; strcpy(ptr1,"c"); strcpy(ptr2,"questions"); printf("\n%s%s",ptr1,ptr2); a)cquestions b)c (null) c)(null) (null) d)compiler error e)none of the above 10.what is the output of the following program int huge *a=(int huge *)0x59990005; int huge *b=(int huge *)0x59980015; if(a==b) printf("velammal Institute of Technology"); else printf("cse"); 3
a)velammal Institute of Technology b)cse c)csecse d)compilation error e)none of the above 4 www.profmariamichael.com 11.What would be the output of the foll program #include<string.h> register a=25; int far *p; p=&a; printf("%d",*p); a)25 b)4 c)address d)compilation error e)none of the above 12.What would be the output of the foll program #include<string.h> char far *p,*q; printf("%d%d",sizeof(p),sizeof(q)); a)2 2 b)4 4 c)4 2 d)2 4 e)none of the above 13.What would be the output of the foll program
int a=10; void *p=&a; int *ptr=p; printf("%u",*ptr); a)10 b)address c)2 d)compilation error e)none of the above 14.What would be the output of the foll program #include<string.h> int register a; scanf("%d",&a); printf(%d",a); //if a=25 a)25 b)address c)0 d)compilation error e)none of the above 15.What would be the output of the foll program char arr[100]; arr="world"; printf("%s",arr); 5
a)world b)w c)null d)compilation error e)none of the above 16. Which of the following gives the memory address of a variable pointed to by pointer a? A. a; B. *a; C. &a; D. address(a); 17.What would be the output of the foll program #include<string.h> int a,b,c,d; char *p=(char*)0; int *q=(int*q)0; float *r=(float*)0; double *s=0; a=(int)(p+1); b=(int)(p+1); c=(int)(p+1); d=(int)(p+1); printf("%d%d%d%d",a,b,c,d); a)2 2 2 2 b)1 2 4 8 c)1 2 2 4 d)compilaion error e)none of the above 18.What will be output of following program? #include<conio.h> 6
void (*p)(); int (*q)(); int (*r)(); p = clrscr; q = getch; r = puts; (*p)(); (*r)("coding and debugging"); (*q)(); (A) NULL (B) coding and debugging (C) c 7 www.profmariamichael.com 19.What will be output of following program? int i = 3; int *j; int **k; j=&i; k=&j; printf( %u %u %d,k,*k,**k); (A) Address, Address, 3 (B) Address, 3, 3 (C) 3, 3, 3 20.What will be output of following program? #include<string.h> int a = 5,b = 10,c; int *p = &a,*q = &b; c = p - q;
printf("%d", c); (A) 1 (B) 5 (C) -5 21.What will be output of following program? unsigned long int (* avg())[3] static unsigned long int arr[3] = 1,2,3; return &arr; unsigned long int (*ptr)[3]; ptr = avg(); printf("%d", *(*ptr+2)); (A) 1 (B) 2 (C) 3 22.What will be output of following program? int * p, b; b = sizeof(p); printf( %d, b); (A) 2 (B) 4 (C) 8 8
9 www.profmariamichael.com 23.What will be output of following program? int i = 5, j; int *p, *q; p = &i; q = &j; j = 5; printf("value of i : %d value of j : %d",*p,*q); (A) 5 5 (B) Address Address (C) 5 Address 24.What will be output of following program? int i = 5; int *p; p = &i; printf(" %u %u", *&p, &*p); (A) 5 Address (B) Address Address (C) Address 5 25.What will be output of following program? int i = 100; printf("value of i : %d addresss of i : %u",i,&i);
i++; printf("\nvalue of i : %d addresss of i : %u",i,&i); (A)value of i : 100 addresss of i : Address value of i : 101 addresss of i : Address (B)value of i : 100 addresss of i : Address value of i : 100 addresss of i : Address (C)value of i : 101 addresss of i : Address value of i : 101 addresss of i : Address 26.What will be output of following program? char far *p =(char far *)0x55550005; char far *q =(char far *)0x53332225; *p = 25; (*p)++; printf("%d",*q); (A) 25 (B) Address (C) Garbage (E)None of above 27.What will be output of following program? int I = 3; int *j; int **k; j = &i; k = &j; 10
printf( %u %u %u,i,j,k); (A) 3 Address 3 (B) 3 Address Address (C) 3 3 3 www.profmariamichael.com 28.What will be output of following program? main() printf("%d, %d", sizeof('c'), sizeof(100)); A) 4, 100 B) 2, 100 C) 2, 2 D) 4, 4 E)None of the above 29.What will be output of following program? void func1(int (*a)[10]) printf("ok it works"); void func2(int a[][10]) printf("will this work?"); main() int a[10][10]; func1(a); func2(a); A) Ok it workswill this work? B) Will this work? C) Ok it works D) Compiler error E)None of the above 11
30.What is the output for the program given below typedef enum errortypewarning, error, exception,error; main() error g1; g1=1; printf(\"%d\",g1); a)compiler error: Multiple declaration for error b)garbage error c)no error d)0 31.What is the output of the following? main() int i; i = 64/square(4);//since / and * r given equal priority,its exec as 64/4*4=(64/4)*4 printf("%d\",i); a) 16 b) 4 c) 64 d) error 32.What will be the output of the following statement? /* /* printf("hello"); */ */ a) hello b) no output c) error d) "hello" 33.What will be the output of the following statements? int a = printf("00"); printf("%d",a); a) 0 b) 00 c) 002 12
d) garbage value 34. extern int x; printf("%d",x); int x = 10; what is the output? a) error b) 0 c) garbage value d) 10 35. What will be the output of the following program? struct p int a,c ; float b; d = 1; printf("%d%d%f",d.a,d.c,d.b); a) garbage value b) 100.0 c) error d) 000.0 36.How many times the following program will print "hello"? printf("hello"); main(); a) 1 b) 2 13
c) infinite number of times d) none of these www.profmariamichael.com 37.What will be the output of the following statements? float c = 1.3; printf("%d%d",sizeof(c),sizeof(1.3)); a) 44 b) 48 c) 42 d) 24 38.What will be the output of the following statement? printf("hello""""world"); a) error b) hello""""world c) hello d) helloworld 39.What will be the output of following statements? char x[ ] = "hello hi"; printf("%d%d",sizeof(*x),sizeof(x)); a) 88 b) 18 c) 29 d) 19 40.What will be the output of following program? printf("%d"); a) error b) no output c) %d d) 0 14