You are on page 1of 9

1. Is this valid?

a struct a { struct b *next;}; struct b { struct a *next;}; a)yes b)error b'coz structure b is used before declaration c)error bcoz both struct a & b use a pointer with the same name d)both b & c 2. forward references are c 1) not allowed in structure/union/enumeration tag names 2) allowed in structure/union/enumeration tag names 3) allowed in function calls, where the name of the function is undeclared 4) allowed in labels after goto statements where that label is declared later a)1 only b)1, 3 &4 c)2, 3 &4 d)4 only 3.what is the output? int main() { int i = fun(); } fun(int i) { printf("%d",i); } a)garbage value b)0 c)type mismatch in redeclaration of fun d)missing argument 4. Error is due to line b 1 int a = 10; 2 int b = b + a; 3 int main() 4 {int local = global;} 5 int global = 10; 6 void fun() 7 {int local = global;} a)2 b)4 c)no error d)5 5. what is the output? int main() { int* i,j; int a=5,b=6; i=&a; j=&b; *i++; *j++; printf("%d..%d",*i,*j);

} a)garbage values b)6..7 c)error d)compiler dependent 6. which of the declarations are/is correct? 1)const volatile int unsigned static a; 2)int const static volatile unsigned a; 3)unsigned const static volatile int a; 4)volatile const int unsigned static a; a)1 only b)2 only c)3 only d)4 only e)all the 4 7. what is the output? c int foo(); int main() { int i=foo(); } int foo() { int * iPtr; { int i = 10; iPtr = &i; } { int k = 20; } printf("%d", *iPtr); } a)10 b)20 c)10 or 20 d)error 8. what is the output? #include<stdio.h> #include<conio.h> int foo(int); int main() { struct name {int name ;} name; int dummy=10; int nam; name : nam=foo(dummy); } int foo(int foo) { foo:

printf("%d",foo); } a)garbage value b)error c)10 d)compiler dependent 9. Error is due to line c 1 int main() 2{ 3 extern static int I; 4 typedef static int b; 5} a)no error b)3 &4 c)3 only d)4 only 10. what is the output? struct temp{ int i; const int j; }; int main() { struct temp temp1; temp1.i=10; temp1.j=20; printf("%d..%d",temp1.i,temp1.j); } a)10..20 b)Lvalue required c)const cannot be modified d)compiler dependent 11. what is the output? int main() { int i,j; i=sizeof(32767); j=sizeof(32768); k=sizeof((int)32768); printf("%d..%d..%d",i,j,k); } a)2..2..2 b)2..4..2 c)4..2..2 d) error: can't store long in int 12. what is the output? int main() { int i = 0; i = ! ~ - sizeof(i) ;

printf("%d", i); } a)2 b)error c)-1 d)0 13. what is the output? int main() { int i=10,j=10,k; k=sizeof(i++ + (++j + ++i)); printf("%d..%d..%d",i,j,k); } a)10..10..2 b)12..11..2 c)error:lvalue required d)13..11..2 14. what is the output? #define SIZE 5 void swap(int *i, int *j) { *i = *i + *j;*j = *i - *j;*i = *i - *j; } int main() { int i; int arr[SIZE] = { 1,2,3,4,5}; for(i=0; i<SIZE; i++) swap(&arr[i], &arr[SIZE-i-1]); for(i=0; i<SIZE; i++) printf("%d ",arr[i]); } a)5 4 3 2 1 b)1 2 3 4 5 c)1 2 0 4 5 d)5 4 0 2 1 15. what is the output? a int main() {int b=100; int a=50; int c=(a,b)?(b,a)?a:b:a; printf("%d",c); } a)50 b)100 c)error d)compiler dependent 16. what is the output? c int main() {int b=(10,20);

int a=(30,50); a=a<<4+b; printf("%d..%d",a,b); } a)error b)820..20 c)0..20 d)80..20 17. what is the output? int main() { int a=20; a=(a>0)?(a++):(a+=2); printf("%d",a); } a)20 b)21 c)22 d)23 18. what is the output? int main() { signed char ch=5; while(ch=ch--) printf("%d",ch); } a)5 4 3 2 1 b)4 3 2 1 0 c)error d)infinite loop 19. what is the output? int main() { enum bool{true, false} boolVar, *boolPtr; boolPtr=&boolVar; *boolPtr=true; printf("%d",*boolPtr); } a)1 b)0 c)error d)garbage value 20. what is the output? int main() { struct someStruct{ int i;

float j; }aStruct; void *ps1 = (void *)&aStruct.i; void *ps2 = (void *)&aStruct.j; if(ps1<ps2) printf("This always gets printed"); else printf(" improper usage"); } a)This always gets printed b)improper usage c)error:expression syntax d)error:can't convert to void* 21. what is the output? c char *try1() { char *temp = "str const"; return temp; } char *try2() { char temp[] = "char str"; return temp; } char *try3() { char temp[] = {'c','h','a','r','s','\0'}; return temp; } int main() { puts(try1()); puts(try2()); puts(try3()); } a)str const char str c b)s c c c)str const garbage value garbage value d)garbage value garbage value garbage value 22. what is the output? int main() { char string[10]; strncpy(string ,"Tom cruise",3)[3] = '\0';

puts(string); } a)error:function strncpy should have a prototype b)Tom c)Tom cruise d)error:expression syntax 23. what is the output? int main() { struct structure1 {int i;}s1={1}; struct structure2 {int i;}s2={2}; s1 = *((struct structure1 *) &s2); printf("\n%d %d",s1.i, s2.i); } a) 2 2 b)1 2 c)1 1 d)error 24. what is the output? int main() { struct bitField {int day:3;int sex: 1; }sample; enum workingDay{mon=2,tue,wed,thur,fri}; #define MALE 0 #define FEMALE 1 sample.day = fri;sample.sex = FEMALE; printf("\n day = %d, sex = %d", sample.day , sample.sex); } a)error b)6 1 c)-2 -1 d)2 1 25. what is the output? #define unsigned int k int main() { union{ float flt; struct{ k mantissa3 :8; k mantissa2 :8; k mantissa1 :7;k exponent :8; k sign:1; }bitField; }floatVar={-1}; printf("no:%f\n",floatVar.flt); }

a)error b)-1.000000 c)-1.000000 d)-1.000000 0 0 26. what is the output? int i = 10; int * foo() { puts("foo( )"); return &i; } int main() { *foo() = 100; printf("%d", i); } a)foo() 100 b)foo() 10 c)foo() garbage value d)foo() 0 27. what is the output? char *wish() { static char s[20]="Wake up"; printf("%s\n",s); return s; } int main() { strcpy(wish(),"Good morning"); wish(); } a) Good morning Good morning b)Wake up Good morning c)error d)Good morning garbage value 28. what is the output? d int main() { int i = 0; scanf("%c", &i); // input 0 (zero) is given here printf("%d", i); } a)0 b)error c)garbage value d)48

29. what is the output? #define PLUS + int main() { int i = 10; PLUS+i; printf("%d", PLUS+i); } a)12 b)11 c)10 d)error 30. what is the output? int main() { char t[10],s[10]="something"; strncpy(t,s,4); t[4]='\0'; puts(t); } a)error:strncpy must have a prototype b)something c)some d)garbage value

You might also like