Vous êtes sur la page 1sur 60

C APTITUDE QUESTIONS

1.Which header file should you include if you are to develop a function that can accept variable number of arguments? 1.Vararg.h 2.stdlib.h 3.stdio.h 4.stdarg.h Answer : 4 2. In a C program, constant is defined 1. 2. 3. 4. before main. after main. anywhere, but starting on a new line. none of the above.

Answer : 3 3. printf(%d.printf(tim*)); 1. 2. 3. 4. result in a syntax error. outputs tim3. output garbage. prints tim and terminates abruptly.

Answer : 2 4.The rule for implict type conversion in C is 1. 2. 3. 4. int<unsigned<float<double. unsigned<int<float<double. int<unsigned<double<float. unsigned<int<double<float.

Answer : 1 5.Which of the following statements is correct? 1. 2. 3. 4. C provides no input-output features. C provides no file access features. provides no features to manipulate composite objects. all of the above.

Answer : 4 6.Integer division in a C program results in 1. 2. 3. 4. truncation. rounding. overflow. none of the above.

Answer : 1 7.For C programming language,which of the following statements is (are) true ? 1. 2. 3. 4. Constant expression are evaluated at compile time. String constants can be concatenated at compile time. Size of the array should be known at compile time. all of the above.

Answer : 4 8. In a C expression involving || operator, evaluation 1. 2. 3. 4. will be stopped if one of its components evaluates to false. will be stopped if one of its components evaluates to true. takes place from right to left. takes place from left to right.

Answer : 4 9.Which of the following statements is (are) correct ? 1. 2. 3. 4. enum variables can be assigned new values. enum variables can be compared. enumeration feature does not increase the power of C. all of the above.

Answer : 4 10.Which of the following comments regarding the reading of a string,using scanf (with option) and gets is true ? 1. Both can be used interchangeably.

2. scanf is delimited by end of line, while gets is not 3. scanf is delimited by blank , while gets is not. 4. none of the above. Answer : 3 11.Which of the following comments about the ++ operator is (are) correct? 1. 2. 3. 4. 5. It is unary operator. The operand can come before or after the operator. It can not be applied to an expression. It associates from the right. all the above.

Answer : 5 12.When a variable of data type double is converted into float then 1. 2. 3. 4. rounding takes place. truncation takes place. the lower order bits are dropped. none of the above.

Answer : 1 13.Which of the following C statements is syntactically correct? 1. 2. 3. 4. for(); for(;); for(,); for(;;);

Answer : 4 14.Consider for loop in a C program.If the condition is missing 1. 2. 3. 4. it is assumed to be present and taken to be false. it is assumed to be present and taken to be true. it results in a syntax error. execution will be terminated.

Answer : 2 15.Which of the following statements about for loop are correct ? 1. Index value is retained outside the loop.

2. index value can be changed from within the loop. 3. Goto can be used to jump,out of the loop. 4. All of the above. Answer : 5 16.Arrays can be initialized provided they are 1. 2. 3. 4. automatic. external. static. both (2) and (3) above.

Answer : 4 17.Arrays are passed as arguments to sa function by 1. 2. 3. 4. value. Reference. both (1) and (2) above. none of the above.

Answer : 2 18.It is necessary to declare the type of a function in the calling program if 1. 2. 3. 4. the function returns an integer. the function returns a non-integer value. the function is not defined in the same file. none of the above.

Answer : 2 19The declaration void function 1(int)indicates the function 1 is a function which 1. 2. 3. 4. has no arguments. returns nothing. both(1) and (2) above. None of the above.

Answer : 2 20.recursive functions are executed in a 1. Last in first out order.

2. First in first out order. 3. Parallel fashion. 4. all of the above. Answer : 1 21.When a function is recursively called,all automatic variables 1. 2. 3. 4. are initialized during each execution. are retained from the last execution. are maintained in a stack. none of the above.

Answer : 1 22.A static variable 1. cannot be initialized. 2. is initialized once at the commencement of execution and cannot be changed at run time. 3. retains its value throughout the file of the program. 4. is same as an automatic variable but is placed at the head of a program. Answer : 2 23.An external variable 1. 2. 3. 4. is globally accessible by all functions has a declaration extern associated with it when declared within a function. will be initialized to 0 if not initialized. all of the above.

Answer : 4 24.A switch statement is used to 1. switch between functions in a program. 2. switch from one variable to another variable. 3. to choose from multiple possibilities which may arise due to different values of a single variable. 4. to use switching variable. Answer : 3 25.The statement #include<math.h>is written at the top of a program to indicate

1. the beginning of the program. 2. the program does heavy mathematical calculations 3. that certainly information about mathematical library functions are to be included at the beginning of the program. 4. none of the above. Answer : 3 26.What is the output of the following C program? main( ) { extern int I; i=20; printf(%d,sizeof(i)); } 1. 2. 3. 4. 2 4 would vary from compiler to compiler. Error, i underdefined.

Answer : 4 27. What is the output of the following C program? main( ) { extern int a; printf(\n%d,a); } int a=20; 1. 2. 3. 4. 0 20 Error. Garbage value.

Answer : 2 28. What is the output of the following C program? main( )

{ extern int fun(float); int a; a=fun(3.14); printf(%d,a); } int fun(aa); float aa; { return ((int)aa); } 1. 2. 3. 4. 3.14 3.0 0 Error.

Answer : 4 29. What is the output of the following C program? main( ) { int a[5]={2,3}; printf(\n%d %d %d,a[2],a[3],a[4]; } 1. 2. 3. 4. Garbage values. 233 322 000

Answer : 4

30. What is the output of the following C program? main( ) { Struct emp { char name[20]; int age; flat sal; };

struct emp e={Tiger}; printf(\n%d%d%f,e.age,e.sal); 1. 2. 3. 4. Error. Garbage value 00.0000000 10.000000

Answer : 3 31.In the following C program,find the error,if any? main( ) { int i=1; for(; ;) { printf(%d,i++); if(i>10) break; } } 1. The condition is in the for loop is must. 2. the two semicolons should be dropped. 3. the for loop should be replaced by a while loop. 4. No error. Answer : 4 32.In the following C program,find out the error in the while loop,if any ? main( ) { int i=1; While( ) { printf(%d,i++); if(i>10) break; } } 1. the condition in the while loop is a must. 2. there should be atleast a semicolon in the while( ). 3. the while loop should be replaced by for loop.

4. No error. Answer : 1 33. What is the output of the following C program? main( ) { int i=2; printf(\n%d%d,++i,++i); } 1. 2. 3. 4. 3 4 4 3 4 4 output may vary from compiler to compiler.

Answer : 4 34. What is the output of the following C program? main( ) { int x=10,y=10,z=5,i; i=x<y<z; printf(\n%d,i); } 1. 2. 3. 4. 1 0 Error. 5

Answer : 1 35.Consider the following C statement.what is the order in which functions are called? A=f1(23,14)*f2(12/4)+f3(); 1. 2. 3. 4. f1,f2,f3 f3,f2,f1 the order may vary from compiler to compiler. None of the above.

Answer : 3

36.In the following Ccode in which order the functions would be called? a= (f1(23,14)*12(12/4))+f3(); 1. 2. 3. 4. f1,f2,f3 f3,f2,f1 The order may vary from compiler to compiler. None of the above.

Answer : 3 37. What is the output of the following C program? main( ) { float a=0.7; if(a<0.7) printf(C); else Printf(C++); } 1. 2. 3. 4. C C++ Error. None of the above.

Answer : 1 38. What is the output of the following C program? main( ) { float a=0.7; if(a<0.7f) printf(C); else printf(C++); } 1. 2. 3. 4. C C++ Error None of the above.

Answer : 2 39. What is the output of the following C program? main( ) { printf(%f,sqrt(36.0)); } 1. 2. 3. 4. 6.0 6 6.000000 Some absurd value.

Answer : 4 40.We want to round off x,a float, to an int value.What is the correct way to do so? 1. 2. 3. 4. y=(int)(x+0.5) y=int(x+0.5) y=(int) x+0.5; y=(int)((int)x+0.5).

Answer : 1 41.What error are you likely to get when you run the following program? main( ) { struct emp { char name[20]; float sal; } struct emp-e[10]; int I; for(i=0;<=9;i++) scanf(%s%f,e[i].name,&e[i].sal); 1. 2. 3. 4. Suspicious pointer conversion Floating pint formats not linked Cannot use scanf( )for structures. Strings cannot be nested inside structures.

Answer : 2 42.By default any real number in C is treated as 1. 2. 3. 4. a float a double a long double Depends upon the memory model that you are using.

Answer : 2 43. What is the output of the following C program? main( ) { pritnf(%d%d%d,sizeof(3.14f),sizeof(3.14),sizeof(3.14I)); } 1. 2. 3. 4. 444 4 Garbage value 4 8 10 Error

Answer : 3 44.If the binary equivalent of 5.375 in normalized form is 0100 0000 1010 1100 0000 0000 0000,0000 what is the output of the following program ? main( ) { float a=5.375; char *p; int I; p=(char *)&a; for(i=0;i<=3;i++) Printf(%02x,(unsigned char)p[i];); } 1. 2. 3. 4. 40 AC 00 00 00 CA 00 40 00 00 Ac 40 00 00 CA 04

Answer : 3

45.What error would the following function given on compilation ? f(int a,int b) { int a; a=20; return a; } 1. 2. 3. 4. Missing parantheses is return statement The function should be defined as int f(int a, int b) Redeclaration of a None of the above.

Answer : 3 46.How many times the following C program would print Jamboree ? main( ) { printf(\nJamboree); main(); } 1. 2. 3. 4. Infinite number of times. 32767 times. 65535 times. Till the stack doesn`t overflow.

Answer : 4 47. What is the output of the following C program? main( ) { printf(5+Fascimile); } 1. 2. 3. 4. Error Fascimile mile None of the above

Answer : 3 48. What is the output of the following C program? main( ) { char str1[]=Hello char str2[]=Hello if(str1== str2) printf(\nEqual); else pirnt(\nUnequal); } 1. 2. 3. 4. Equal Unequal error None of the above.

Answer : 4 49. What is the output of the following C program? main( ) { printf(%c,abcdefgh[4]); } 1. 2. 3. 4. Error d e abcdefgh

Answer : 3 50. What is the output of the following C program? main( ) { char str[7]=Strings; printf(%s,str); } 1. Error 2. Strings 3. Cannot predict

4. None of the above. Answer : 3 51. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived object,. calling of that virtual method will result in which method being called? a. Base method b. Derived method.. Ans. b 52. For the following C program #define AREA(x)(3.14*x*x) main() { float r1=6.25,r2=2.5,a; a=AREA(r1); printf("\n Area of the circle is %f", a); a=AREA(r2); printf("\n Area of the circle is %f", a); } What is the output? Ans. Area of the circle is 122.656250 Area of the circle is 19.625000 54.Find output: void main() { int d=5; printf("%f",d); } Ans: Undefined 55. Find the output: void main() { int i; for(i=1;i<4,i++) switch(i) case 1: printf("%d",i);break; {

case 2:printf("%d",i);break; case 3:printf("%d",i);break; } switch(i) case 4:printf("%d",i); } Ans: 1,2,3,4 56. Find the output: void main() { char *s="\12345s\n"; printf("%d",sizeof(s)); } Ans: 6 57. Find the output: void main() { unsigned i=1; /* unsigned char k= -1 => k=255; */ signed j=-1; /* char k= -1 => k=65535 */ /* unsigned or signed int k= -1 =>k=65535 */ if(i<j) printf("less"); else if(i>j) printf("greater"); else if(i==j) printf("equal"); } Ans: less 58. Find the output void main() { float j; j=1000*1000; printf("%f",j); } 1. 1000000 2. Overflow 3. Error

4. None Ans: 4 59. Find the Output: int f() void main() { f(1); f(1,2); f(1,2,3); } f(int i,int j,int k) { printf("%d %d %d",i,j,k); } What are the number of syntax errors in the above? Ans: None 60. Find the Output: void main() { int i=7; printf("%d",i++*i++); } Ans: 56

61. Find the Output #define one 0 #ifdef one printf("one is defined "); #ifndef one printf("one is not defined "); Ans: "one is defined" 62. Find the Output void main() { int count=10,*temp,sum=0; temp=&count; *temp=20;

temp=&sum; *temp=count; printf("%d %d %d ",count,*temp,sum); } Ans: 20 20 20 63. Find the output main() { static i=3; printf("%d",i--); return i>0 ? main():0; } Ans: 321 64. Find the output char *foo() { char result[100]); strcpy(result,"anything is good"); return(result); } void main() { char *j; j=foo() printf("%s",j); } Ans: anything is good. 65. Find the output: void main() { char *s[]={ "dharma","hewlett-packard","siemens","ibm"}; char **p; p=s; printf("%s",++*p); printf("%s",*p++); printf("%s",++*p); } Ans: "harma" (p->add(dharma) && (*p)->harma) "harma" (after printing, p->add(hewlett-packard) &&(*p)->harma)

"ewlett-packard" 66. Output of the following program is main() {int i=0; for(i=0;i<20;i++) {switch(i) case 0:i+=5; case 1:i+=2; case 5:i+=5; default i+=4; break;} printf("%d,",i); } } a) 0,5,9,13,17 b) 5,9,13,17 c) 12,17,22 d) 16,21 e) Syntax error Ans. (d) 67. What is the ouptut in the following program main() {char c=-64; int i=-32 unsigned int u =-16; if(c>i) {printf("pass1,"); if(c<u) printf("pass2"); else printf("Fail2"); } else printf("Fail1); if(i<u) printf("pass2"); else printf("Fail2") } a) Pass1,Pass2 b) Pass1,Fail2 c) Fail1,Pass2 d) Fail1,Fail2

e) None of these Ans. (c) 68. What will the following program do? void main() { int i; char a[]="String"; char *p="New Sring"; char *Temp; Temp=a; a=malloc(strlen(p) + 1); strcpy(a,p); //Line number:9// p = malloc(strlen(Temp) + 1); strcpy(p,Temp); printf("(%s, %s)",a,p); free(p); free(a); } //Line number 15// a) Swap contents of p & a and print:(New string, string) b) Generate compilation error in line number 8 c) Generate compilation error in line number 5 d) Generate compilation error in line number 7 e) Generate compilation error in line number 1 Ans. (b) 69. In the following code segment what will be the result of the function, value of x , value of y {unsigned int x=-1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); } a) same, MAXINT, -1 b) not same, MAXINT, -MAXINT c) same , MAXUNIT, -1 d) same, MAXUNIT, MAXUNIT e) not same, MAXINT, MAXUNIT Ans. (a) 70. What will be the result of the following program ? char *gxxx()

{static char xxx[1024]; return xxx; } main() {char *g="string"; strcpy(gxxx(),g); g = gxxx(); strcpy(g,"oldstring"); printf("The string is : %s",gxxx()); } a) The string is : string b) The string is :Oldstring c) Run time error/Core dump d) Syntax error during compilation e) None of these Ans. (b) 71. Find the output for the following C program main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); } Ans. An empty string 72. Find the output for the following C program main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } Ans. 57 94 73. Find the output for the following C program main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); }

Ans. 5 20 1 74. Find the output for the following C program #define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } Ans. 10 5 75.Find the output for the following C program main() { char *ptr = "Ramco Systems"; (*ptr)++; printf("%s\n",ptr); ptr++; printf("%s\n",ptr); } Ans. Samco Systems 76.Find the output for the following C program #include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } Ans. Compilation error giving it cannot be an modifiable 'lvalue'

76.Find the output for the following C program #include<stdio.h> main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) malloc(25); strcpy(p1,"Ramco"); strcpy(p2,"Systems"); strcat(p1,p2); printf("%s",p1); } Ans. RamcoSystems 77. Find the output for the following C program # define TRUE 0 some code while(TRUE) { some code } Ans. This won't go into the loop as TRUE is defined as 0 78. struct list{ int x; struct list *next; }*head; the struct head.x =100 Is the above assignment to pointer is correct or wrong ? Ans. Wrong 79.What is the output of the following ? int i; i=1; i=i+2*i++; printf(%d,i);

Ans. 4

80. FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2) } Find the Error, If Any? Ans. no error. But It will over writes on same file. 81. Find the output: void main() { int i=7; printf("%d",i++*i++); } Ans: 56 82. #define MAN(x,y) (x)>(y)?(x):(y) {int i=10; j=5; k=0; k=MAX(i++,++j); printf(%d %d %d %d,i,j,k); } Ans. 10 5 0 83.Find the output: #include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; };

struct xx *s; printf("%d",s->x); printf("%s",s->name); } Answer: Compiler Error 84. Find the output: main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); } Answer: 45545 85. Find the output: #include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); } Answer: 50 86.Find the output: main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }

Answer: Compiler error: Undefined label 'here' in function main

87. Find the output: main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); } Answer: 1 88. Find the output: #include<stdio.h> main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); } Answer: M 89.main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(\n %d %d %d, ptr-p, *ptr-a, **ptr); *ptr++; printf(\n %d %d %d, ptr-p, *ptr-a, **ptr); *++ptr; printf(\n %d %d %d, ptr-p, *ptr-a, **ptr); ++*ptr; printf(\n %d %d %d, ptr-p, *ptr-a, **ptr); }

Answer: 111 222 333 344 Find the output: main ( ) { static char *s[ ] = {black, white, yellow, violet}; char **ptr[ ] = {s+3, s+2, s+1, s}, ***p; p = ptr; **++p; printf(%s,*--*++p + 3); } Answer: ck 91. Find the output: #define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); } Answer: TRUE 92. Find the output: main() { int *j; { int i=10; j=&i; } printf("%d",*j);

91.

} Answer: 10 93. Find the output: int i=10; main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); } Answer: 30,20,10 94. Find the output: # include<stdio.h> aaa() { printf("hi"); } bbb(){ printf("hello"); } ccc(){ printf("bye"); } main() { int (*ptr[3])(); ptr[0]=aaa; ptr[1]=bbb; ptr[2]=ccc; ptr[2](); } Answer: bye 95. Find the output void main() {

static int i=5; if(--i){ main(); printf("%d ",i); } } Answer: 0 0 0 0 Find the output: main() { float f=5,g=10; enum{i=10,j=20,k=50}; printf("%d\n",++k); printf("%f\n",f<<2); printf("%lf\n",f%g); printf("%lf\n",fmod(f,g)); } Answer: Line no 5: Error: Lvalue required Line no 6: Cannot apply leftshift to float Line no 7: Cannot apply mod to float

95.

96. Find the output void pascal f(int i,int j,int k) { printf(%d %d %d,i, j, k); } void cdecl f(int i,int j,int k) { printf(%d %d %d,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); } Answer:

10 11 12 13 12 11 10 13 97. What is the output of the program given below main{ signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); } Answer: 128 98. What is the output of the program given below main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); } Answer: Compier Error: '&' on register variable 99. What is the output of the program given below main() { void swap(); int x=10,y=8; swap(&x,&y); printf("x=%d y=%d",x,y); } void swap(int *a, int *b) { *a ^= *b, *b ^= *a, *a ^= *b; } Answer: x=10 y=8

100. {

main() int i = 257; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }

Answer: 1 1 101.Find the Output: #include <stdio.h> main() { int i; i =0x10+010+10; printf("%d",i); } ans : 34 102. Find the Output: main() { int x; x = 4 % 5 + 6 % 5; printf("x = %d",x); } ans : 5 103. Find the Output: main() { int i; float j; i =5/2; j =5/2; printf("%f %d ",j,i); } ans : 2.000, 2 104. Find the Output: main() { float a =12.25,b =13.25; if(a = b) printf("RISC"); else printf("CISC"); } ans : RISC

105. Find the Output: main() { int x =100; if(!!x) printf("x =%d",!x); else printf("x =%d",x); } ans : 0 106. Find the Output: main() { long i=65536 +65; printf("%c\n",i); char a; printf("%d",a); } ans:error. 107. Find the Output: main() { int q =2,d=3,st; st = q*d/4-12/12+12/3*16/d; printf("st =%d",st); } ans : 21 108. Find the Output: main() { printf("%d %f\n",4,4); printf("%d %f\n",4.0,4.0); } ans : 4 garbage 00

109. Find the Output: #define MEAN(a,b,c,d,e) (a+b+c+d+e)/5 main() { int a,b,c,d,e,m; a=1;b=2;c=3;d=4;e=5; m = MEAN(a,b,c,d,e); printf("Mean of the five numbers is =%d",m); } ans : 3 110. Find the Output: main() { printf("%d",1&2); } ans : 0 111. Find the Output: main() { int x; x =3 * 4 % 5; printf("x = %d",x); } ans : 12 112. Find the Output: main() { printf("%d %d %d %d ",72,072,0x72,0X72); } ans : 72 58 114 114 113. Find the Output: main() { printf("%d", 4||2); } ans : 1

114. Find the Output: main() { printf("%d",3||2); } ans : 1 115. Find the Output: main() { printf("%d",3&&2); } ans : 1 116. Find the Output: main() { int g = 300 * 300 /3; printf("g =%d",g); } ans : 8154 117. Find the Output: main() { printf("%d",3>2); } ans : 1 118. Find the Output: main() { float x = 5.5,y=8.0; x*= ++x;/*for float there is no effect in using post ++*/ y++; printf("%f %f",x,y); } ans 42.25 9

119. Find the Output: main() { int x=2,y,z,s; x*= y=z=4; s=(y==z); printf("%d\n",x); printf("%d",s); } ans : 8 1 120. Find the Output: main() { int x,y,z; x=2;y=1;z=0; x=(x&&y)||z; printf("%d\n",x); printf("%d\n",x||y&&z); x=y=1; z=x++ -1; printf("%d\n",x); printf("%d\n",z); z+= x++ + ++y; printf("%d\n%d\n",x,z); } ans : 1 1 2 0 3 4 121. Find the Output: main() { int x = 0,z,y; z = !x|x; y = x|!x; printf("%d %d",z,y); }

ans : 1 1 122. Find the Output: main() { int i=100,j=200; printf("%d%d"); } ans : 100 200 123. Find the Output: main() { int x = 2,z; for(x=2;x<=10;x++) { printf("%d\t",x); printf("%d\n",~x); } x=2; z = ~(x|x); printf("%d",z); } ans : 2 -3 3 -4 ... 10 -11 -3 124. Find the Output: main() { int x=1,y=1,z=1,aa; x+=y+=z; printf("%d %d %d\n",x,y,z); aa = x<y?x++:y++; printf("%d",aa); } ans : 3,2,1,2 125. Find the Output: main()

{ int x=-1,y=-1,z=-1,a; a=(x++ && y++) || ++z; printf("%d %d %d %d", x,y,z,a); } ans :0,0,-1,1 126. Find the Output: main() { int y=100,x; x = y= y++; printf("%d %d ", x,y); } ans : 100, 101 127. Find the Output: #include<stdio.h> main() { int x,y=1,z; if (z=(y==1)) x=5; else x=10; printf("x=%d\t y = %d\t z=%d ",x,y,z); } ans:5 1 1 128. Find the Output: # include<stdio.h> main() { int x,y=1,z; if (z=y<0) x=3; else if (y==0) x=5; else x=7; printf ("%d %d %d",x,y,z); } ans : 7 1 0 129. Find the Output: #include<stdio.h> int i=0;

main() { auto int i=1; printf("%d\n",i); { int i=2; printf("%d\n",i); { i+=1; printf("%d\n",i); } printf("%d\n",i); } printf("%d\n",i); } ans : 1 2 3 3 1 130. Find the Output: # include<stdio.h> main() { int a=6; a+= a++ + ++a; printf("%d",a);} ans : 22 131. Find the Output: main() { static char food[]="yummy"; char *ptr; ptr=food + strlen(food); while (--ptr>=food) puts(ptr); } ans : y my mmy ummy yummy 132. Find the Output: main()

{ int i =10; #include<stdio.h> printf("%d",i); } ans : 10 133. Find the Output: # define FUN(k) a+b/*d-bc*/c main() { int a,b,c,*d,bc; a=6;b=5;c=4;bc=2; d=&c; printf("%d\n",FUN(K)); } ans : 8 134. Find the Output: main() { int x,a,b,c; a=10;b=5;c=5; x=a==b + c++; printf("%d",x); } ans : 1 135. Find the Output: include<stdio.h> main() { int *a=71; printf("%d %d",a,*a); } ans : garbage 136. Find the Output: # include<stdio.h> main() { static int arr[]={ 97 ,98 ,99 ,100 ,101 ,102 ,103 ,104 };

int *ptr = arr+1; print(++ptr,ptr--,ptr,ptr++,++ptr); } print(int *a,int *b,int *c,int *d,int *e) { printf("\n%d %d %d %d %d",*a,*b,*c,*d,*e); } ans : 100 100 100 99 99 137. Find the Output: #include <stdio.h> main() { int i; int a[] = {1,2,3,4,5,6,7}; for(i=0;i<=4;i++) { printf(" %d ",a[i]); } } ans : 1 2 3 4 5 138. Find the Output: main() { int a,i; i = 11; a = i++ + ++i + --i; printf("%d %d",a,i); } ans:33 12 139. Find the Output: main() { int i=10; printf("\n value of i =%d address of i =%u",i,&i); &i==7200; printf("\nnew value of i=%d new address of i =%u",i,&i); } ans : no change

140. Find the Output: main() { int *i,*j,**k; j=i+2; k =&i; printf("\nk=%u j=%u i=%u",*k,j,i); } ans : addr pnted by i, addr pnted + 4, addr in i 141. Find the Output: #include <stdio.h> main() { union{ struct cathy{ int cathy; char joe; }cat; int m; }ass; printf("\nsize of :%d " ,sizeof(ass)); } ans : 3 142. Find the Output: #include<stdio.h> main() { int i=3,j; j= i++ * ++i * ++i; printf("%d %d",j,i); } ans : 125 6 143. Find the Output: main() { int aa0aa1aa2aa3aa4aa5aa6aa7aa8aa9aazz1zz2 =10; printf("%d",aa0aa1aa2aa3aa4aa5aa6aa7aa8aa9aa); }

ans : 10 (Compiler dependent) 144. Find the Output: #include<stdio.h> main() { char in; while ((in = getchar())!= '*') { if ((in >= 'a') && (in <='z')) another(); } } another() { static int i=0; i++; printf("%d",i); } ans : if abc* is given as input then output is 123 145. Find the Output: #include<stdio.h> main() { int stud[5][2]={ {1234,56}, {1212,33}, {1434,80}, {1312,78}, {1203,75} }; int i,j; for(i=0;i<=4;i++) { printf("\n"); for(j=0;j<=1;j++) printf("%d",*(*(stud+i)+j)); } } ans: 123456 121233 143480 ..

146. Find the Output: # include <stdio.h> # define BYTESIZE main() { int printbits(int); int x =5; printbits(~x); } printbits(x) int x; { int i; for(i=0;i<BYTESIZE*sizeof(x);++i) printf("%d",(val <<i&1<<BYTESIZE*sizeof(int)-1)?1:0); putchar('\n'); } ans : error. 147. Find the Output: #include <stdio.h> main() { int i=12,j=3,k =2; /* 1 + 1 = 0 & 1+0 | 0+1 = 1 for XOR /* prece => compli ,AND,OR,XOR printf("%d ",i^j&~k); printf("%d %d",i & j,i & j && k); } ans : 13 0 0 148. Find the Output: main() { /* !x gives 0 for +ive & -ive values ;one for 0 */ int x = 2; printf("!x = %d\n",!x); printf("%d\n",!x|x); printf("%u\n",~x|x); printf("%u\n",x<<1); printf("%u\n ",x>>1);

*/ */

} ans : 0 2 65535 (Depends on the machine) 4 1 149. Find the Output: #include<stdio.h> main() { int a,b,c;e a = b =c= -1; ++a || ++b && ++c ; printf("a = %d ,b = %d , c = %d",a,b,c); } ans : 0 0 -1 150. Find the Output: #include<stdio.h> main() { int a,b,c; a = b = -2; c = ++a && ++b ; printf("a = %d ,b = %d , c = %d",a,b,c); } ans : -1 -1 1 151. Find the Output: #include<stdio.h> main() { int x,y,z; x = y = 0; while(y <10) { x += ++y; printf("%d %d\n",x,y); } }

ans : 1 1 32 63 10 4 15 5 21 6 28 7 36 8 45 9 55 10 152. Find the Output: main() { int x=1,y=1; if (y<0) if (y>0) x=3; else x=5; printf("%d",x); } ans : 1 153. Find the Output: #include<stdio.h> main() { int c,nd =0,no =0; while((c =getchar())!= '\n') switch(c) { case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : nd++; default: no++;

break; } printf("%d %d ",nd,no); } ans : when input is 123abc<enter> , nd=3 no = 6 154. Find the Output: main() { int x,y=1,z; if (x=y=z);x=3; printf("%d %d",x,z); } ans : x=3 z=garbage 155. Find the Output: main() { int a,b; a =-3 - -3; b =-3 - -(-3); printf("a = %d b =%d",a,b); } ans : a=0 b=-6 156. Find the Output: #include<stdio.h> main() { long count; count = 62000+1536+10; printf("%ld ",count); } ans : 63546 157. Find the Output: main() { long i; i =65536+300; printf("%ld ",i); }

ans : 65836 158. Find the Output: main() { int *a; *a = 1; printf("%d %d",a,*a); } ans : garbage, 1 159. Find the Output: #include <stdio.h> int a[][2] ={1,2,3,4}; main() { int i,j; int (*p)[2]=a; for(i=0;i<2;i++) { for(j=0;j<2;j++) printf("%u \t\t%u \n",*p+j,*(*p+j)); p++; } } ans : 158 160 162 164 1 2 3 4

160. Find the Output: main() { int *a=1; printf("%d %d",a,*a); } ans : 1, garbage 161. Find the Output: main() { char a[]={"jeban"};

printf("%*s",(40+strlen(a)),a); } 162. Find the Output: #include <stdio.h> void cube(int *,int *,int *); main() { int x=5,y,z; cube(&x,&y,&z); printf("value of x =%d",x); printf("\nIts cube =%d",z); } void cube(int *a,int *b,int *c) { *b = (*a)*(*a); *c = (*b)*(*a); } ans: x=5 z=125 163. Find the Output: main() { int i=2,j=3,k; k=i+++j; printf("%d %d %d",i,j,k); } ans : 3 3 5 164. Find the Output: compute(int m,int n) { if(m==0) return(n+1); else { if(n==0) compute(m-1,1); else compute(m,compute(m-1,n)); } } main()

{ int i; i = compute(2,3); printf("%d",i); } ans : bull shitting question 165. Find the Output: main() { int i=0; char *cat ="city\0ki0ng"; while(*cat++) { i++; printf("%d\n",i); } } ans : 1 2 3 4 166. Find the Output: #include <stdio.h> int i; main() { char joe[10] = "city\0ki0ng"; char ch; for(i=0;(ch=joe[i]!=0);i++) { ch=ch+'a'-'A'; printf("%d\n",ch); } } ans : 33 33 33 167. Find the Output: #include <stdio.h> main() { FILE *fp; char str[20];

fp = fopen("new.out","w"); if(fp == 0) printf("File opening error"); else { printf("Enter your name:"); scanf("%s",str); fprintf(fp,"%s",str); fclose(fp); } } ans : too simple 168. Find the Output: #include <stdio.h> main() { FILE *fp; char a; fp = fopen("old.out","w"); if(fp == 0) printf("File opening error"); else { for(scanf("%c",&a);a!=EOF;scanf("%c",&a)) fprintf(fp,"%c",a); fclose(fp); } } ans : same as the previous one 169. Find the Output: main() { int a=(10,15,12,77); printf("%d ",a); } ans : 77 170. Find the Output: main() { char a;

printf("%d",(2^3)+(a^a)); } ans: 1 171. Find the Output: main() { int i = 5; printf("%d",i); return(99121123323213232323224224333332223234423323232323234234224 2422 printf("hai"); } ans : 5 172. Find the Output: main() { int i=4,*j,*k; j=&i; printf("\n%d\n",j); j=j+1; printf("\n%d\n",j); j=j+9; k=j+3; printf("%d %d %d ",i ,j ,k); } ans : too simple 173. Find the Output: #include<stdio.h> #include<conio.h> #define CL printf("%c%c%c%c",27,91,50,74) #define MC(x,y) printf("%c%c%d%c%d%c",27,91,x,59,y,72) #define VR printf("%c%c%c%c",27,91,55,109) #define VB printf("%c%c%c%c",27,91,53,109) #define VO printf("%c%c%c%c",27,91,53,109) main() { CL; MC(12,33); printf("hai");

VR; /*macro for reverse video on */ printf("\nhallo"); VO; /*macro for reverse video off */ printf("\nbye" );g MC(17,25); VB; /* macro for video blink */ printf("\nHELLO"); } ans : prints some Garbage value 174. Find the Output: main() { printf("%d",0.3.); } ans : error. 175. Find the Output: main() { int a=3,b=2; if (a=b) printf("The two numbers are same"); else printf("The two numbers are not same"); } ans : two numbers are same 176. Find the Output: #include <stdio.h> main() { char *s="abc"; char *t; for (t=s;*t!='\0';++t) { switch (*t) { case 'a': putchar('1'); case 'b': putchar('2'); case 'c': putchar('3');

break; } } putchar('\n'); } ans : 123233 177. Find the Output: #include <stdio.h> main() { struct word { char *string; int length; }; struct word dict[2]; struct word *p =dict; p->string = "structure";p->length =9; (++p)->string ="word";p->length= 5; printf("%d\n",(--p)->length); printf("%c",*(p->string)); } ans : 9 s 178. Find the Output: #include <stdio.h> char *strchr(char *s,char c) { while(*s++!= c); return s; } main() { char str[30]; gets(str); puts(strchr(str,'a')); } ans : input given "juggernauts"; output is uts 179. Find the Output:

#include <stdio.h> void main(void) { int i=5; printf("\n%d",i); change(i/2); printf("\n%d",i); i=change(i/2); printf("\n%d",i); } int change(int i) { return i<=5 ? 2 : 5 ; } ans : 5 5 2 180. Find the Output: #include <stdio.h> main() { printf("%d",func()); } int func() { _AX=100; } ans : 100 181. Find the Output: #include <stdio.h> char *mycopy(str) char *str; { char ptr[20]; strcpy(ptr,str); return(ptr); } main() { char name[20]; char parm[20];

strcpy(name,"malini"); parm =mycopy(name); puts(parm); } ans : error 182. Find the Output: # include<stdio.h> # include<ctype.h> main() { char a; a = getchar(); if isupper(a) printf("entered value is upper"); else printf("entered value is lower"); } ans : input 'a'. output: entered value is lower 183. Find the Output: main () { int a = 10,b=5; a ^=b^=a^=b; printf("%d %d ",a,b); } ans : 5 10 184. Find the Output: main() { float a=0.131200; printf("%d ",a); } ans : 0 185. Find the Output: #include <stdio.h> main() { int *i,j;

i =&j; i =i+ 5; printf("%d %d",i,&j); } ans : (compiler dependent) &j+10, &j 186. Find the Output: main() { char a[10],*pc; int j; pc = a; pc =pc + sizeof(a); j=pc-a; printf("%d",j); } ans : 20 187. Find the Output: main(){ int i=0; char *ptr="LION\0ABCD"; while(*ptr++) i++; printf("%d",i); } ans: 4 188. Find the Output: main(){ int i,j,num=1; for(i=1;i<=100;i++) { for(j=1;j<=100;j++) num+=1; } printf("%d",num); } ans: 10001 189. Find the Output: main(){ int c=027E,i;

for(i=0;i<8;i++) { if(get(c,i)) printf("*"); else printf("+"); } } int get(b,n) int b,n; { if(b&((i<<7)>>(n%8))) return 1; else return 0; } ans: +******+ 190. Find the Output: main(){ char input[]="ssswILTECH.\0RMP'1'" while(input[i]!='\0') switch(c){ case 'i':break; case 1: while(c=input[i]!='\0') continue; case 'L': putchar(L); default: putchar(c); } putchar("_"); } ans: ssswILTECH 191. Find the Output: main(){ char cmyname(void); char *str="DCMDATASYSTEM" while(*str++!='\0') putc(cmyname); } char cmyname(void) { return ("abcdefghijklmnopqrstuvwxuyz"); }

ans: dcmdatasystems 192. Find the Output: main(){ int h; int bh=2; int high=0258 h=high<<8+bh printf("the number is %u",h); } ans:(error) 193. Find the Output: main(){ unsigned char uc= (unsigned ) 128 signed char gc=(signed )0200 uc>>=1 gc>>=1 printf("%f%c",uc,gc) } ans: 64,64 194.Find the Output: main(){ int a[]={1,2,5,6,9,10}; int *b=&a[4]; printf("\n%d",b[-3]); } ans:6 195. Find the Output: main(){ int x=0,y=1; if(x=y) y= 7; else y=2; value of y? } ans:7 196. Find the Output: main(){

int n=39,count=0; while( i & 1) //some condition like this { count++; i>>1; } } value of count? ans:4 197. Find the Output: main(){ int x=128; printf("\n%d",1+x++); } ans:129 198. Find the Output: #define max 10 main(){ printf("\n%d",max++); } ans:compiler error 199. Find the Output: struct list{ int x; struct list *next; }*head; the struct head.x =100 Is the above assignment to pointer is correct or wrong ? Ans. Wrong 200. Find the Output: #include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1);

} Ans. Compilation error giving it cannot be an modifiable 'lvalue'