Sunteți pe pagina 1din 23

1.

What is the output when the following code is executed?

main() { int a=20,b; b=(a= =1)?2:3; printf(\n a=%d,b=%d\n,a,b); } a)a=20,b=2 2. b)a=1,b=2 c)a=20,b=3 d)a=1,b=3

What is the output when the following code is executed?

main() { int a=20,b; b=(a=1)?2:3; printf(\n a=%d,b=%d\n,a,b); } a)a=20,b=2 b)a=1,b=2 c)a=20,b=3 d)a=1,b=3

3.

What is the output when the following code is executed? { for(i=1;i<=5;++i) { if(i<=4) break; printf(%d,i); } } a)1 2 3 b) 1 2 3 4 c) 1 2 3 4 5 d) no output

4. What is the output when the following code is executed? #include<stdio.h> main() { int x=10,y=15,a,b; a=x++; b=++y; printf(%d , %d ,a,b); } a)10,16 b)11,15 c)11,16d)10,15 5. Which of the following statement is true? a) break statement is used to terminate the execution of the program. b) continue statement is used to terminate the execution of the loop. c) exit() function is used to jump out of a loop. d) break statement is used to exit from a loop or from a switch case structure 6. Which of the following statement is true? a) break statement is used to terminate the execution of the program. b) continue statement is used to terminate the execution of the loop. c) exit() function is used to jump out of a loop. d) continue statement is used inside a loop to bypass a section of the loop and continue the execution with next iteration of the loop. 7. Which of the following statement is true? a) break statement is used to terminate the execution of the program. b) continue statement is used to terminate the execution of the loop. c) exit() function is used to jump out of a loop. D) exit() function is used to terminate the execution of a program.

8. Originally x=4,y=3 and z=0 . What are values of x,y,z after executing the following code? switch(x) {

case 0 : x=2;y=3; case 1 : z=4; break; default : ++x; } a)x=0,y=3,z=4 b)x=2,y=3,z=4 9. Expression (x<5||a>b) is true

c)x=1,y=3,z=4

d)x=5,y=3,z=0

a) if x<5 b) if a>b c) if x<5 or a>b d) all the above

10. What is the output when the following program segment is executed? int a[5]={71,82,69,69,78}; for(i=0;i<5;++i) printf(%c,a[i]); a) green b) GREEN c) 71 82 69 69 78 d) syntax error 11. What value is assigned to k when the following statements are executed? int i=8,j=20,k; k=(++i , j-- , i*j); a) 171 b)180 c)168 d)160 12. Which of the following is not a basic data type in C? a) int b)double c)void d)printf

13. What is the output of the following code? char ch=A; printf(%d,ch+10); a)10 b)75 c)74 d)double

14. Which of the following statement is used to exit from a switch case statement? a) exit b)continue c)goto d)break

15. What value is assigned to c when the following code is exectued? int a=5,b=6,c; c=(a+b>a-b)?a*b;a%b; a)30 b)5 c)0 d)6

16.How many times KLU is printed? for(i=0;i>5;++i) printf(KLU\n); a)6 b)5 c)0 d)Indefinite no of times.

17.How many times KLU is printed? for(i=0;i<5;++i); printf(KLU\n); a)6 b)5 c)1 d)Indefinite no of times.

18.What is the output when the following code is executed ? int i=0; while(i<=5); { printf(KLU\n); ++i; } a)6 b)5 c)1 d)no output 19. Which of the following is not a library function in C? a) clrscr() b)exit() c)goto() d)getch()

20. Which of the following is exit control loop? a)for b)switch case c)while d)do-while

21. What is the output when the following code is executed? #include<stdio.h> void main() { int a[6]={12,13}; printf(\n %d%d,a[2],a[3]); } a) 13,0 b) 0 , 0 c) 0, garbage value d)13,garbage value 22. What is the output of the following program? #include<stdio.h> main()

{ int i=1; for( ; ; ) { printf(\n %d,++i); if( i>5) break; } } a) 2 3 4 5 b) 1 2 3 4 5 c)2 3 4 5 6 d)1 2 3 4 5 6 23. What is the C expression for the following mathematical expression. 1<x20 or 3y1 a) 1<x <=20 || 1<=y<=3 b) 1<x <=20 && 1<=y<=3 c) (1<x && x<=20) || (3>=y && y>=1) d) any one of the above 24. What is the value assigned to k when the following statements are executed? int k,a=5,b=3,c=10; k=(a + = b *= c - = 6); a)17 b)12 c)10 d)5

25. What is true about the following: a compound statement is a) A set of simple statements b) Demarcated on either side by curly bracket c) Can be used in place of simple statement d) All the above. 26. What is the value of y in the following code? x=7,y=0; if(x = 6) y=7; else y=1; a)7 b)0 c)1 d)6

27. Which of the following represents true statement either x is in the range of 10 and 50 or y is 0? a) x>=10&&x<=50||y==0 b)x<50 c)y!=10 d)None of these

28. Consider the following program segment

int n sum=1; switch(n) { case 2: sum=sum+2; case 3: sum*=2; break; default : sum=0; } If n=2 ,What is the value of sum a)0 b)6 c)3 d)None of these

29. Regarding real values in C which of the following is true i) A float occupies less memory than a double. ii) The range of real numbers that can be represented by a double is less than those represented by a float a) only option i b)only option ii c)both i and ii d)neither i nor ii

30. The modulus operator can be applied only to _____ types a) integer b) character c) floating point d) all the above three types 31. The operator % yields a) Quotient value c)percentage value b)Remainder value d)fractional part of the division.

32.Whch of the following is a ternary operator? a) ?: b)* c)sizeof d)&&

33. Which of the following statements is/are true? i)A char data type variable always occupies 1 byte independent of system architecture. ii)sizeof is a key word iii)include is a key word. iv)double is not a keyword. a)both i&ii b) i only c)ii only d)neither i nor ii

34.Which of the following is a loop construct? a)if-else b)switch-case c)goto d)while

35.When is default statement executed in switch case construct?

a) When ever there is exactly one match. b)When ever break statement is omitted in all case statements c)When ever there is no match with case labels. d)options b and c. 36. Omitting the break statement from a particular case in switch case construct a) leads a syntax error b)causes execution of the program to terminate after the case c) causes execution to continue all subsequent cases. d) causes execution to branch to the statement after the switch statement 37. What is the value of z after the following statements executed? int x=2,y=2,z=1; if(x=y%2) z+=10; else z+=20; a)21 b)11 c)1 d)the expression x=y%2 is not allowed

38. What is the output of the following program? main() { unsigned int i; for(i=10 ; i>=0 ; - - i) printf(%d,i); } a) prints numbers from 10 to 0 c) prints numbers from 10 to -1 39.Array name is a) is always an integer type c)A common name shared by all elements 40. Array elements occupy a)adjacent memory locations b)Random location for each element c)Varying length of memory locations for each element. d) no space in memory. b)a key word d)not used in a program b) prints numbers from 10 to 1 d)An indefinite loop is formed

41. Array is used to represent a)a list of data items of integer data type. b) a list of data items of real data type. c) a list of data items of different data type. d) a list of data items of same data type. 42. Array subscripts in C always starts at a)-1 b)0 c)1 d)any value

43.If the size of the array is less than the number of initializes a)Extra values are neglected b)It is an error c)The size is automatically increased d) The size is neglected. 44. Which of the operator is having highest precedence? a)* b)++ c)= d)&&

45. How many times x is printed? for(i=0 , j=10 ; i < j ; ++i , --j) printf(x);; a)10 b)5 c)4 d)none

46. What is the output for the program bellow? #include<stdio.h> main() { int i; for(i=1;i<=5;++i) { if(i==3) continue; printf(%d\t,i); } } a) 1 2 4 5 b) 1 2 3 4 5 c) 4 5 47. Which is not a valid expression

d) 1 2

a)-p++

b)++p--

c)++6

d) +x++

48.Which of the following is not a keyword in C? a)const b)main c)case d)void

49. An identifier cannot start with a)underscore b)uppercase alphabet 50. What is the output of the following code? main() { int a=300,b=100,c=50; if(a>400) b=300; c=200; printf(\n b=%d c=%d,b,c); } a) b=100 c=200 b)b=300 c=200 c)b=100 c=50 d) b=300 c=50 51. Which of the following is the correct output for the program given bellow? #include<stdio.h> int main() { float a=0.7; if(0.7>a) printf(hi \n); else printf(hello \n); return 0; } a)Hi b) hello c)hi hello d)None of the above 52. What is the output of the following program? #nclude<stdio.h> main() { int i; for(i=1;i<=5;++i) { if(i==3) break; c)lower case alphabet d)#

printf(%d \n,i); } } a) 1 2 4 5 b) 1 2 3 4 5 c) 4 5 d) 1 2 53.What is the output of the following code? main() { int a=500,b=100,c=50; if(a>400) { b=300; c=200; } c=100; printf(\n b=%d , c=%d \n,b,c); } a) b=100 c=200 b)b=300 c=200 c)b=300 c=100 d) b=300 c=50 54.What is the value assigned to C? int a=10,b=6,c; c=a++*b; a) 60 b)66 c)61 d) none of the above

55. What is the output of the following code? int a=10; printf(a=%d,a++); a) a=10 b) a=11 c) a=12 d) a=9 56. What is the output of the following code? int x=20,y=16,z; z=(x<y)&&(y+=2); printf(y=%d,z=%d,y,z); a) y=18 z= 0 b)y = 16 z=0 c) y=16 z=1 d) y=18 z=1

58 What is the output of the following code? int x=20,y=16,z; z=(x>y)&&(y+=2); printf(y=%d,z=%d,y,z);

a) y=18 z= 0 b)y = 16 z=0

c) y=16 z=1 d) y=18 z=1

59. What is the output of the following code? int x=20,y=16,z; z=(x<y)||(y+=2); printf(y=%d,z=%d,y,z); a) y=18 z= 0 b)y = 16 z=0 c) y=16 z=1 d) y=18 z=1

60.What is the output of the following code? int x=20,y=16,z; z=(x>y)||(y+=2); printf(y=%d,z=%d,y,z); a) y=18 z= 0 b)y = 16 z=0 61 . Which of the following is true? int a=5,b=7; if(a<b); a++; else b++; printf(a=%d,b=%d \n,a,b); a)a=6,b=8 b)a=6,b=7 c)a=5,b=8 62. Which of the following is true? int a=5,b=7; if(a<b); { a++; ++b; } printf(a=%d,b=%d \n,a,b); a)a=6,b=8 b)a=6,b=7 c)a=5,b=7 d)syntax error. d)syntax error. c) y=16 z=1 d) y=18 z=1

63. What value is assigned to a? a=5&&0; a) 0 b)1 c) 5 d) 50

64. What value is assigned to x? x=8&&9; a) 0 b)1 c) 8 d)9 65. What is the output when the following program is executed? #include<stdio.h> main() { int i,j; for(i=1;i<=3;++i) { for(j=1;j<=3;++j) printf(%3d ,i+j); printf(\n); } a)2 3 4 b)2 2 2 c)2 3 4 d)1 2 3 345 333 567 456 456 444 789 789 66. What is the output when the following program is executed? #include<stdio.h> main() { int i; for(i=1;i<=10;++i); printf(%d,i); } a) First 10 natural numbers can be displayed

c) Natural numbers starting from 1 are displayed indefinitely d) no output.

b) 11

67) What is the output when the following program is executed? #include<stdio.h> main() { int i=1; while(i<=10) { printf(%d,--i); ++i; } }

a)Integers from 0 to 10 are printed b) the sequence 0 1 01 01 printed indefinitely c) 0 is printed indefinitely d) first 10 natural numbers are printed. 68) What is the output when the following program is executed? #include<stdio.h> main() { int a=1; while(a<=5) { if(a==2) continue; printf(%d\t,a); a += 2; } } a) 1 3 5 b) 1 2 3 5 7 c) 1 d)no output 69. What is the output of the following program? #include<stdio.h> void main() { int i; for(i=1;i<=7; ++i) { if(i<=4) printf(%d , i); else printf(%d ,8-i); } } a) 1 2 3 4 b) 3 2 1 c)1 2 3 4 5 6 7 d)1 2 3 4 3 2 1 70) What is the output when the following program is executed? #include<stdio.h> main () { int x=1; for( ; ; ) { if(x==3) break; printf(%d\t,x); break; } }

a) no output

b) 1 2 c) 1 d) syntax error as all the three expressions are missing in for

71) What is the output when the following program is executed? #include<stdio.h> main() { int x=1; while(1) { printf(%d,x); ++x; } a) 1 b)1 2 c)2 3 4 5 d)1 2 3 4 72. What is the output when the following program is executed? #include<stdio.h> main() { int x=1; while() { printf(%d,x); ++x; } a)syntax error b)1 2

c)2 3 4 5 d)1 2 3 4

73) What is the output when the following program is executed? #include<stdio.h> main() { int a[5]={1,2,3,4,5},sum=0,i=0; begin: sum+=a[i]; ++i; if(i<5) goto begin; printf(%d,sum); } a) syntax error b) 15 c)10 d) 25 74) What is the output when the following program is executed? #include<stdio.h> main() {

int a=10; do { printf(%d,a); --a; } while(a<=1); } a) 10 b)10 9 1

c) 1 2 310 d) syntax error

75) What is the output when the following program is executed? #include<stdio.h> main() { int a=5; while(a-- >0) printf(%d\t,a); } a)5 4 3 2 1 a) 4 3 2 1 0 c) 5 4 3 2 1 0 d) 4 3 2 1 76) What is the output when the following program is executed? #include<stdio.h> main() { int a=5; for(a=5;--a >0; ) printf(%d\t,a); } a)4 3 2 1 b)5 4 3 2 1 c) 4 3 2 1 0 d)5 4 3 2 1 0 77) What is the output when the following program is executed? #include<stdio.h> main() { int a; for(a=10;! i;-- i) printf(%d,i); } a) First 10 natural numbers are printed in reverse order c) 10 d) no output. 78) What is the output when the following program is executed? #include<stdio.h> main() { int b; for(b=3;b<10;b=7)

b)11

printf(%d,b); } a)3 4 5 6 7 8 9

b) 7 7 7

c) 3 7 7 7 7

d)3

79) What is the output when the following program is executed? #include<stdio.h> main() { int p=5; while(p<8) { printf(%d,p); p=9; } } a)5 6 7 b)5 c)5 9 9 9 9 d) no output 80) What is the output when the following program is executed? #include<stdio.h> main() { int i; for(i=10;++i ; i-=12) printf(%d,i); } a)11 b)0 c)12

d)11,-1,-13,

81) What would be the output when the following program is executed? #include<stdio.h> main() { int i=4; for(--i ; --i ; --i) printf(%d,i); } a)2 0 -2 -4 -6 b)4 3 1 -1 -3 c)2 1 0 d)2 82) What would be the output when the following program is executed? #include<stdio.h> main() { int i; for(i=0;i--;i--) printf(%d,i); }

a)0 b)no output c) -1 ,-3,-5 d)-1 83) What would be the output when the following program is executed? #include<stdio.h> main() { int x=3456,sum=0; for( ;x>0;d=x%10,sum+=d,d/=10); printf(%d,sum); } a)0 b)18 c)6 d)output statement is not executed 84)What is the value assigned to x when the following statement is executed? x = 2*8*6/ 15%13; a)5 b)96 c)6 d)6.4

85)What is the value assigned to a? int x = 5, y = 3, z = 4, a; a = x = y = =z; a) 5 b)3 c)4 d)0

86)What is the value assigned to a? int a, x=2; a = x + 3 * x++; a)9 b)8 c)15 d)12

87)What is the output of the following program? #include<stdio.h> main() { int x=3, y=17, a;

a = x += y%= 6; printf( a = %d, a); } a)a=8 b)a=0 c)a=3 d)a=6

88)What is the output of the following program? #include<stdio.h> main() { int x= 5; printf( %d , %d , %d, ++x, x , x ++); } a)7,6,5 b)6,6,7 c)5,6,7 d)6,6,6

88.What is the output of the following program? #include<stdio.h> main() { int x= 10; printf( %d , %d , %d, x , x++, ++x); } a)10,11,12 b)12,12,11 c)10,10,12 d)12,11,11

89) What value is assigned to d? int a = 1, b = 2, c=5,d; d = a * b > = c;

a)1

b)2

c)0

d)syntax error in the assignment statement

90)What value is assigned to the integer variable a? a = + = = 0; a) 0 b)1 c)0.5 d)1.0

91)What is the output when the following program is executed?

#include<stdio.h> main() { int a = 5, b = 0, c ; c = a || b ++ ; printf (b = % d, c = %d, b, c); } a)b=0,c=1 b)b=1,c=0 c)b=1,c=1 d)b=0,c=0

92)What is the output when the following program is executed? #include<stdio.h> main() { int a = 5, b = 0, c ; c = a && b ++; printf ( b = %d, c = %d \n, b, c); }
a) b=1, c=1 b) b=0, c=1 c) b=0, c=0 d) b = 1, c =0

93)What is the output of the following program? #include<stdio.h>

main() { int a = 5, b = 6, c ; c = a < b ? a : a > b ? b : -1; printf ( c = %d \n, c ); } a) -1 b)1 c)5 d)6 94) What will be printed by the following code? #include< stdio.h> main() { int x = 5; switch(x) { case 5 : printf (%d\t, x * x) ; case 6 : printf(%d\t, x + 1 * x+1); default : break; } } a)25 11 b)25 31 c)25 36 d)25 95.What will be the output when the following code is executed? #include<stdio.h> main() { int a = 6; while (a) { printf(%d\t, a); a -= 2; } } a)6 4 2 0 b)6 4 2 c)6 5 4 2 1 d)6 5 4 3 2 1 96. What is the output when the following program is executed? #include<stdio.h> main() { int a[5] = { 1 } , i ; for ( i = 4; i> = 0; --i ) printf ( %d \t, a[i]); } a)1 1 1 1 1 b)0 0 0 0 1 c)4 3 2 1 d)1 0 0 0 0 97. What is the output when the following program is executed? #include<stdio.h> main() {

int a[5], i; for( i=0; i < 5; ++i) a[i] = i * i ; for( i=0; i< 5 ; ++i) printf(%d , a[i]); } a)1 2 3 4 b)1 4 9 16 25 c)0 1 4 9 16 d)0 1 2 3 4 98.What is the output when the following program is executed? #include<stdio.h> main() { int a[5] = { 3,1, 10, 20, 30},i=0; x = ++a[1]; y = a[1]++; z = a[++i]; printf( x= %d , y = %d, Z = %d \n , x, y, z ); } a)x=2,y=2,z=3 b)x=4,y=3,z=1 c)x=2,y=3,z=3 99) What is the output when the following program is executed? #include<stdio.h> void main() { float a= 7.8, b= 3.95, c, d; c = (int) (a/b) ; d = (int) a / (int) b; printf( c = % .2 f , d = % . 2f \n, c, d ); } a)c=1.97,d=1.97 b)c=1.00,d=2.00 c)c=1.97,d=2.33 d)c=0,d=0

d)x=1,y=1,z=1

100) Which of the following statements are correct about the problem given below? #include<stdio.h> main() { float a = 2.8, b = 2.87 ; if (a = b) printf( a and b are equal \n); else printf(a nd b are not equal \n); } a) The statement if (a = b) results in a compilation error. b) floats cannot be compared using if

c) In the if statement the values of a and b are not compared for equality

d) switch_case should be used to compare floats. 101) What is the output when the following program is executed? #include<stdio.h> main() { int x = 10; printf( %d , %d, %d , x < = 20, x= 25, x >= 5); } a)20 ,25,5 b)1,25,1 c)0,25,1 d)10,25,1 102) What is the output when the following program is executed? #include<stdio.h> main() { int a = 3, b = 0, c; c = ++a && ++b; printf ( a = %d, b = % d, c= %d \n , a, b, c); } a)a=3,b=0,c=0 b)a=3,b=0,c=1 c)a=4,b=1,c=1 d)a=4,b=1,c=0 103) What is the output when the following program is executed? #include<stdio.h> main() { int i = -3, J=2, k=0, m; m= ++i && ++J || ++k; printf( i = %d, j = %d, K = %d, m=%d\n, i, J, k, m ); } a) i=-3,j=2,k=0,m=1 b)i=-2,j=3,k=1,m=1 c)i=-2,j=3,k=1,m=0 d) i=-2,j=3,k=0,m=1 104) What is the output when the following program is executed? #include<stdio.h> main() { int a=5,b,c; b=++a; c=a++; printf(a=%d,b=%d,c=%d,a,b,c); } a)a=5,b=5,c=6 b)a=7,b=6,c=6 c)a=5,b=6,c=7 d)a=5,b=6,c=6 105) How many times KLU is displayed when the following code is executed?

#include<stdio.h> main() { int x; for(x=-1;x<=5;++x) { if(x<3) continue; else break; printf(KLU \n); } a)5 b)6 c)4 d)0 106)what is the output when the following program is executed? #include<stdio.h> main() { int a=1,b=1; for( ; b ; printf(%d,%d\n,a,b),b=a++<=3 ); a) 107)What is the wrong assignment expression in the following? float a,b,x=8.2,y=6.3; a)a=x%6 b)b=x>y c)a=x+y/3.5 d)x-y*3.6

S-ar putea să vă placă și