Sei sulla pagina 1di 43

 1.What is the output of the following problem ?

#include
int main()
{
int i=4;
if(i=0)
printf("statement 1");
else
printf("statement 2");
return 0;
}

A. statement 1
B. statement 2
C. Compilation Error
D. No Output
Option B
Explanation:
statement 1 will only be printed when i value=0. But i value is initialized as i=4 so it doesn't go with
the first condition hence the second condition is accepted and statement 2 is printe

2.. int main()


{
int const * p=5;
printf("%d",++(*p));
return 0;
}
A. Compiler error
B. 5
C. 6
D. None of these
Option A
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".

 3.What is the output of the following 'C' program?

#include
void main() {
int x = 10,y = 10, z = 5, i;
i = x;
printf("%d",i==x);
}

 A. 1
 B. Error
 C. 0
 D. 5

Option A
Explanation:
The value of x initialised is 10. Also i=x so i=10. Now when comparing condition (i==x) it will give
boolean result that is if the condition is true it will return 1 else it will return 0. So here the condition
is true coz x=i hence output is 1.

4. What does the following 'C' program do ?

#include
void main()
{
unsigned int num;
int i;
scanf("%u", &num);
for (i = 0; i < 16; i++)
printf("%d", (num << i & 1 << 15)? 1:0);
}
A. It prints all even bits form num
B. It prints binary equivalent of num
C. It prints all odd bits from num
D. None of these
Option B
Explanation:
Here integer (unsigned) is assumed as 2 bytes so that for loop is till 16 i.e (2byte = 16 bits.)

As unsigned integer so user is expected to enter positive number.

statement in printf (num << i & 1 << 15)? 1:0 is used to convert decimal to binary equivalent.

in the above statement below things has been used.

<< ----> left shift

& -----> And operator


? : ------> trinery operator

Ex: if the number is 10 and its binary equivalent 1010 or (00000000000001010 in 16 bit)

the printf statement will be

for i = 0

(10 << 0 & 1 << 15)>?1:0

for i = 1

(10 << 1 & 1 << 15)>?1:0

similarly for i = 2, 3, 4 , ---- 15

5. What is the output of the following program ?

include
int main()
{
int x,y=2,z,a;
x = (y*=2) + (z=a=y);
printf ("%d", x);
return 0;
}
A. 7
B. 8
C. 6
D. syntactically wrong
Option B
Explanation:
x = (y*=2) (z=a=y); Meaning of y*=2 means y=y*2 hence y value becomes 2*2=4.
Current value of y =4 so z=a=y=4.
Hence x=4+4=8

6. #include
void main()
{
int x,y=2,z,a;
if(x=y%2)
z=2;
a=2;
printf("%d %d",z,x);
}
A. 1..0
B. 2..0
C. 2..1
D. Garbage-value 0
Option D
Explanation:
The value of y%2 is 0. This value is assigned to x.
The condition will if (0) so z goes uninitialized

7. What is the output of the following 'C' program ?

#include
void fun(void)
{
static int s = 0;
s++;
if(s == 10)
return;
fun();
printf("%d ", s);
}

int main(void)
{
fun();
}

A. 9 times 10
B. 10 times 10
C. Compilation Error
D. None of these
Answer: Option A

8. What is the output of the following 'C' program ?

void main(){
char c=125;
c=c+10;
printf("%d",c);
}
A. 135
B. INF
C. -121
D. Compilation Error
Option C
Explanation:
Here char is signed so,the size of char is 1 bytes and its value range are -128 to 127,and it will be
something like below
-128 -127 -126 .......... 0 ....... 126 127 in the cycle.

Now as per questions c = 125 it is under the above limit.


but when 10 added to it, it becomes 125 10 = 135

125 126 127 -128 -127 -126 -125 -124 -123 -122 -121

So, count above 135 will fall at -121, so Answer will be -121
If in the question it would have given unsigned char then answer will be 135

9. What is the correct way to round off x, a float, to an int value?


A. y = (int)(x + 0.5);
B. y = int(x + 0.5);
C. y = (int)x+ 0.5;
D. y = (int)((int)x + 0.5);
Option A
Explanation:
Rounding off a value means replacing it by a nearest value that is approximately equal or smaller or
greater to the given number.
y = (int)(x 0.5); here x is any float value. To roundoff, we have to typecast the value of x by using (i

10. In C programming language the below statement means.


A. x = x-y + 1
B. x = -x -y - 1
C. x = -x + y + 1
D. x = x -y -1
Answer: Option D
Explanation:
what are these statements n C?

11. What would be the output of the following C program if input to the program is 'e'?

void main ()
{
char lower, upper;
lower = getchar();
upper= toupper (lower);
putchar (upper);
}
A. 53
B. e
C. E
D. Nothing
Answer: Option C

12. What is the following C Program doing?

void main ()
{
char line [80];
gets (line);
puts (line);
}
A. prints horizontal straight lines on screens
B. prints 80 vertical lines on screen
C. reads in a line of 80 characters
D. reads and prints lines composed of characters
Answer: Option D

13. What is the output of the following program ?


void main()
{
printf("%d",10?0?5:1:12);
}
A. 10
B. 0
C. 12
D. 1
Option D
Explanation:
The Answer should be 1, Because the will return the value of condition and printf will print the
output .
10?0?5:1:12 (here 10 is true)->0?5:1(Here 0 is false)-> 1 is output.

14. What is the output of the following program ?

#include
void main()
{
int i= 5;
if (i == 5)
return 0;
else
printf("i is not five");
printf("over");
}
A. a syntax error
B. an execution error
C. printing of overan error message
D. execution termination, without printing anything
Option D
Explanation:
Clearly we can see that i value is initialised 5 and the condition i==5 is also true. Hence return 0;
will be executed and the execution will be terminated without printing anything coz its return 0 and
not print 0.
Return statement brings the control of the program out of the loop

15. What is the output of the following "c" program ?

#include
void main()
{
int i = 107, x = 5;
printf ((x > 7)? "%d" : "%c:, i)
}

A. an execution error
B. a syntex error
C. printing of k
D. none of these
Option C
Explanation:

printf ((x > 7)? "%d" : "%c:, i) x value assigned is 5 hence 5 is not greater than 7 so second
condition i.e (%c:i) will be executed means ascii value of small k is 107 so the character k will be
printed.

16. What is the output of the following C Program?

#include
void main()
{
int a=4, b = 6;
printf ("%d", a==b);
}

A. outputs an error message


B. 0
C. 1
D. none of these
Option B
Explanation:
printf ("%d", a==b); It gives a boolean result i.e 1 for true and 0 for false. Since 4 is not equal to 6
hence output will be 0.
17. Which of the following option is correct for the below program?

#include
void main()
{
int a,b,c;
b=2;
a= 2*(b++);
c = 2*(++b);
}

A. a=4,c=6
B. a=3,c=8
C. b=3, c=6
D. a=4, c=8
E. None of these
Option D
Explanation:
b=2;

a= 2*(b );..........a=2*2=4 Here post increment of b will take place and b value after this line has
executed will become 2 1= 3.

c = 2*( b); Here pre increment will take place and before the excecution of this line b value will
become 3 1=4 hence c= 2*4=8
so o/p= a=4 and c=8.

18. What is the output of the program?

#include
int main ()
{
int ( *Commprintf) (const char*, ... ) = printf;
Commprintf ( "Hello World");
return 0;
}

A. No output
B. Undefined symbol Commprintf
C. Compile Error: Prototype mismatch
D. Hello World
Option D
19. What is the output of the following code?

include
void main()
{
int a=0, b=0;
a = (b =75)+9;
printf("\n%d, %d ",a,b);
}

A. 75, 9
B. 75, 84
C. 84, 75
D. None of these Option
Option C
Explanation:
a = (b =75) 9;......b value is assigned to 75 so a value will become 75+9= 84.
final value will become a=84 and b=75

20. What will be output of the following "c" code?

#include
void main()
{
100;
printf("%d",100);
}

A. Compilation Error
B. 100
C. 1
D. None of these
Option B
Explanation:
100; ...........there was no use of this 100. Its only to confuse the students.

printf("%d",100); ...... its as simple as to print hello world. hence 100 is printed.

21. What will be output of the following "c" code?

#include
void main()
{
int i=10;
i=!i>14;
printf("%d", i);
}

A. 0
B. 10
C. 1
D. Compilation Error
Option A

22. What will be output of the following "c" code?

#include
void main ( )
{
int i;
for( i=0; i<10; i++,printf("%d", i));
}

A. 2345678910
B. 123456789
C. Compilation Error
D. 12345678910
Option D

23. What will be output of the following "c" code?

#include
void main ( )
{
int a=500, b=100,c;
if( !(a>=400))
b=200;
c=200;
printf( "%d %d", b,c);
}

A. 200 100
B. 100 200
C. 200 200
D. Compilation Error
Option B

24. What will be output of the following "c" code?

#include
void main ( )
{
int i, m=2, n=3;
for( i=0;m+n=5; m++)
printf("%d %d", m,n);
}

A. Compilation Error
B. 2 3
C. 3 3
D. 2 3 3 3
Option A
Explanation:
error: lvalue required as left operand of assignment

25. What will be output of the following "c" code?

#include
void main ()
{
int x =400, y;
y = x*x+x;
printf ("% d", y);
}
A. 400
B. 320000
C. Compilation Error
D. 160400
Option D

26. What is the output of the following program?

void main()
{
int x,y, z;
x=2; y=1; z = 1;
if(x > y + z)
printf("Hello!\n");
else if (x < y+ z)
printf ("Hi!\n");
else
printf("Hey!\n");
}
A. Hi!
B. Hey!
C. Hello!
D. None of these
Option B
Explanation:
answer is option B
x>y+Z
2>1+1 = 2>2 false
x<y+z 2<2 false
condition goes to else and prints Hey!

27. What will be output of the following "c" code?

#include
void main ( )
{
int i, m=2, n=3;
for( i=0;m+n=5; m++)
printf("%d %d", m,n);
}

A. Compilation Error
B. 2 3
C. 3 3
D. 2 3 3 3
Option A

28. What would be the output of the following C program ?

void main() {
int = 12345;
float x = 145.678;
printf ("%3d, %5d, %8d", i,i,i,);
}
A. 123 123 123
B. 123,451,234,512,346
C. 12345
D. 123
Option C
Explanation:
i not declared and in printf (,) is the extra is shows error
assume if int i=12345;
and all syntax is right then the answer will be
12345, 12345, 12345
(check in GDB if you have any doubts)

29. Find the output for the following C program

#include
int main()
{
int x=2,y=6,z=6;
x=y==z;
printf("%d",x);
}

A. 3
B. 0
C. None of these
D. 1
Option D

30. Find the output for the following C program

void main
{
int x,j,k;
j=k=6;x=2;
x=j*k;
printf("%d", x);
}

A. 2
B. 36
C. 6
D. None of the above
Answer: Option
31. #include
void main()
{
unsigned short a=-1;
unsigned char b=a;
printf("%d %d ",a,b);
}
What is output of the program?

A. 65535 -1
B. 65535 65535
C. 65535 255
D. -1 -1
E. None of above
Answer: Option C

32. What will be the result of the following program?

#include
int main()
{
static int i;
int j;
for(j=0;j<10;j++)
{
i= i+2;
i = i-j;
}
printf("%d",i);
return 0;
}

A. 25
B. -25
C. 20
D. -20
E. None of these
Option B
Explanation:
can anyone help with this????
33. What will be output of following c program?

#include
long unsigned static const ddlg(){
static const long unsigned a=0101;
return a;
}
int main(){
long number;
number=ddlg();
printf("%X",number);
return 0;
}

A. 41
B. 43
C. Compilation error
D. None of the above
Option A

34. printd (int n)


{
if (n < 0)
{
printf ("-");
n = -n;
}
if (n % 10)
printf ("%d", n);
else
printf ("%d", n/10);
printf ("%d", n);
}

If initially n = -24;
A. -24
B. 24
C. -2424
D. None of the above
Answer: Option C
35. What is the output of the following 'C' program ?

#include
int main()
{
int i = 10 ;
printf("%d\n", i/2 );

}
A. 10
B. 5
C. error
D. warning
Answer: Option B

36. What is the output of the following 'C' program ?

#include
int main()
{
char c = 255;
printf ("%d",c);
return 0;
}

A. illegal character assignment


B. prints -1
C. prints 2
D. prints 255
Answer: Option B

37. What will be output of the following "C" code?

#include
main()
{
100;
printf("%d",100);
}

A. Error
B. 100
C. Garbage value
D. 100100
Answer: Option B

38. Predict the output of following code:

void main()
{
float a=1.1;
double b=1.1;
if(a==b)
printf("equal");
else
printf("not equal");
}
A. ? equal
B. not equal
C. Error
D. equal not equal
Option B

39. Predict the output of following code:

#include
void main()
{
int sum;
char ch1='a';
char ch2='b';sum=ch1+ch2;
printf("%d",sum);
}

A. Error
B. 195
C. 201
D. "ab"
Option B
Explanation:
ascii sum;
sum = 97+98 = 195
40. Predict the output of following code:

#include
void main()
{
int a=b=c=d=10;
printf("%d,%d,%d,%d",a,b,c,d);
}

A. Error
B. 10,10,10,10
C. GV,GV,GV,10
D. GV,GV,GV,GV
Option A
Explanation:
error: 'b' , 'c', 'd undeclared

41. What will be output of the following "C" code?

main()
{
int i=-1;
-i;
printf("%d,%d",i,-i);
}
A. -1, 1
B. -1, -1
C. 1, 1
D. 0, 1
Option A
Explanation:
No change in value of i
42. What could be the output for following "C" code?

main()
{
int a= - - 2;
printf("%d",a);
}
A. 2
B. -2
C. 1
D. Error
Option A

43. What is the output of this C code?

#include
int main()
{
short int i;
scanf("%hd", &i);
printf("%hd", i); return 0;
}

A. Compilation error
B. Undefined behavior
C. Whatever user types
D. None of these
Option C

44. What is the final value of i and final value of LOOPS ?

#include
int main()
{
int i,j,k,l,lc=0;

printf("Enter the number string:<1234 567>\n");


scanf("%2d%d%1d",&i,&j,&k);
for(;k;k--,i++)
for(l=0;printf("%d %d\n",i,l);)
printf("LOOPS= %d\n", lc-1);
}

A. I = 16 and LOOPS=169
B. I = 0 and LOOPS=16
C. Compilation Error
D. No output
Option A
45. What is the output of the following problem ?

#include
int main()
{
int i;
for (i=9;i<13; i++)
printf("%d %0x ",i,i);
return 0;
}

A. 9 9 10 10 11 11 12 12
B. 9 10 11 12
C. 9 9 10 b 11 b 12 c
D. Compilation Error
E. 9 9 10 a 11 b 12 c
Option E

46. #include
int main(){
for(printf("1");!printf("0");printf("2"))
printf("Aditya");
return 0;
}

A. 10Aditya2
B. 10Aditya
C. 10Aditya210Aditya2
D. 10
E. Compilation error
Option D

47. void main()


{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q;
}
for(j=0;j<5;j++){
printf(" %d ",*p);
++p;
}
}
A. 2 3 4 6 5 2 3 4 6 5
B. 2 2 2 2 2 2 3 4 6 5
C. 2.8 3.4 4 6.7 5 2.8 3.4 4 6.7 5
D. None of these
E. Compiler Error
Option B
Explanation:
Here pointer c is assigned to both p and q.
In first loop, only q is incremented and not c , the value 2 will be printed 5 times.
In second loop p itself is incremented. So the values 2 3 4 6 5 will be printed

48. What is the output of the following C Program?

#include
int main()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
return 0;
}

A. 0
B. 1
C. 2
D. None of these
Option B
Explanation:
before entering into the for loop the checking condition is "evaluated". Here it evaluates to 0 (false)
and comes out of the loop, and i is incremented (note the semicolon after the for loop).

49. What is the output of the following C Program?

#include
int main()
{
unsigned int i;
for(i=1;i>-2;i--)
printf("c aptitude");
}

A. c aptitude
B. c aptitude three time
C. no output No Error
D. Compilation Error
E. None of these
Option C
Explanation:
Here "I" is an unsigned integer. It is compared with a signed value. Since the both types doesn't
match, signed is promoted to unsigned value.
The unsigned equivalent of -2 is a huge value so condition becomes false and control comes out of
the loop.

50. What is the output of the following C Program?

#include
void main()
{
while(1){
if(printf("%d",printf("%d")))
break;
else
continue;
}
}

A. Garbage values
B. Compilation Error
C. no output No Error
D. stack Overflow
Option A
Explanation:
The inner printf executes first to print some garbage value. The printf returns no of characters
printed and this value also cannot be predicted. Still the outer printf prints something and so returns
a non-zero value. So it encounters the break statement and comes out of the while statement.
51. What is the output of the following C Program?

#include
void main()
{
signed char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}

A. 256
B. 128
C. -256
D. -128
Option D
Explanation:
Notice the semicolon at the end of the for loop. Tee initial value of the i is set to 0.
The inner loop executes to increment the value from
0 to 127 and then it rotates to the negative value of -128.
The condition in the for loop fails and so comes out of the for loop. It prints the current value of i
that is -128
52.What will be output of the following "c" code?

#include
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
Option B
53. Find out the error in the 'while' loop, if any ?

void main()
{
int i= 1;
while ()
{
printf("%d", i++);
if (i > 10)
break;
}
}
A. The condition in the while loop is a must
B. There should be at least a semicolon in the while ()
C. The while loop should be replaced by for loop
D. No error
Option A

54. What is the output of the following program ?

#include
void main()
{
for (putchar('c');putchar('a');putchar('r'))
putchar('t');
}

A. syntax error
B. catrat
C. catTatratratrat...
D. cartrt
Option C

55. #include
int i;
void main(){
int t;
for ( t=4;scanf("%d",&i)-t;printf("%d\n",i))
printf("%d--",t--);
}
// If the inputs are 1,2,3 find the o/p

A. Compilation Error
B. 4--1 3--0 2--2
C. Run time Error
D. 4--0 3--1 2--2
E. None of these
Option D

56. #include
void main()
{
int i=0;
while(+(+i--)!=0)
i-=i++;
printf("%d",i);
}
A. 2
B. Compilation Error
C. 0
D. 1
E. -1
Option E
Explanation:
Unary + is the only dummy operator in C.

So it has no effect on the expression and now the while loop is,while(i--!=0)which is false and so
breaks out of while loop. The value "-1" is printed due to the post-decrement operator.
57. #include
void main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}

A. -128
B. infinite loop
C. 1 2 3 4
D. None of these
E. Compilation Error
Option A

58. #include
void main()
{
int i = 3;
for (;i++=0;)
printf("%d",i);
}

A. 3 4 5
B. 3 4 5 � continue
C. Compiler Error: Lvalue required.
D. None of these
Option C
Explanation:
As we know that increment operators return rvalues and hence it cannot appear on the left hand
side of an assignment operation.

59. What is the output of the following 'C' program?

#include
void main()
{
static int i;
while(i<=10)
(i>2)?i++:i--;
printf("%d", i);
}

A. Garbage Value
B. Compilation Error
C. 0
D. 2147483647
E. None of these
Option D
Explanation:
Since i is static it is initialized to 0. Inside the while loop the conditional operator evaluates to false,
executing i--.
This continues till the integer value rotates to positive value (2147483647).
The while condition becomes false and hence, comes out of the while loop, printing the i value.

60. What will be output of the following "c" code?


#include
void main()
{
char ch;
for(ch=0;ch<=127;ch++)
printf("%c %d \n", ch, ch);
}

A. Infinte loop
B. 0-127 char
C. Compilation Error
D. None of these
Option A
Explanation:
The char type may be signed or unsigned by default. If it is signed then ch++ is executed after ch
reaches 127 and rotates back to -128. Thus ch is always smaller than 127.

62. hat is the output of the following 'C' program ?

#include
int main()
{
int c = 0;
do
{
int c = 0;
++c ;
printf("\n c = %d ", c );
}
while( ++c <= 3 );
printf("\n c = %d\n", c );
return 0;
}

A. c = 1 c = 1 c = 1 c = 1 c = 4
B. c = 1 c = 1 c = 1 c = 4 c = 4
C. Compilation Error
D. None of these
Option A

63. What is the output of the following 'C' program ?


#include
int main()
{
int i;
for (i = 0; i < 3; ++i)
{
int t = 1;
static int i = 1;
int *ptr = &i;
printf("%d %d\n",t, *ptr);
t = t + 1;
*ptr = *ptr + 1;
}
return 0;
}

A. 1 0 1 1 1 2
B. 1 1 1 2 1 3
C. 1 0 1 0 1 0
D. Compilation Error
Option B

64. What is the output of the following C Program?

void main() {
for(i = 1; i < 5; i++)
{
if (i == 3)
continue;
else
printf ("%d", i);
}
}
A. 1 2 4 5
B. 1 2 4
C. 2 4 5
D. none of these
Option B

65. What is the output of the following C Program?

#include
void main()
{
for (i = 3; i < 15; i += 3);
printf ("%d", i);
}

A. a syntax error
B. an execution error
C. 12
D. 15
Option D

66. What is the output of the following program ?

#include
void main()
{
int i= 5;
do {
putchar (i + 100);
printf("%d", i--);
}while(i);
}

A. i5h4g3flel
B. 14h3g2fle0
C. an error message
D. none of these
Option A

67. What is the output of the following C Program?

#include
void main()
{
for (i =1,j = 10; i < 6; ++i, - -j)
printf("%d%d", i,j);
}

A. 1 10 2 9 3 8 4 7 5 6
B. 1 2 3 4 5 10 9 8 7 6
C. 1 1 1 1 1 9 9 9 9 9
D. none of these
Option A

68. What is the output of the following C Program?

#include
void main()
{
for (i = 3; i < 15; i += 3);
printf ("%d", i);
}

A. a syntax error
B. an execution error
C. 12
D. 15
Option D

69. What is the output of the following program ?

#include
int main()
{
int i,j;
i = j =2;
while ( --i && j++)
printf("%d %d",i,j);

return 0;
}

A. 2 3
B. 0 3
C. 1 3
D. Infinite Loop
Option C
70. What will be output of the following "c" code?

#include

void main() {
int i= 0;
for(; i++; printf("%d", i));
printf("%d", i);
}

A. 1 1
B. 0
C. infinite loop
D. 1
E. None of these
Option D

71.
Which of the following is the correct order if calling functions in the below code?
a = f1(23, 14) * f2(12/4) + f3();
A. f1, f2, f3

B. f3, f2, f1

C. Order may vary from compiler to compiler

D. None of above

Option C
Explanation:
Here, Multiplication will happen before the addition, but in which order the functions would be called
is undefined. In an arithmetic expression the parenthesis tell the compiler which operands go with
which operators but do not force the compiler to evaluate everything within the parenthesis first.

72. What is the right way to access value of structure variable book{ price, page }?

A. printf("%d%d", book.price, book.page);


B. printf("%d%d", price.book, page.book);
C. printf("%d%d", price::book, page::book);
D. printf("%d%d", price->book, page->book);

Answer : A
73. What is right way to Initialization array?

A. int num[6] = { 2, 4, 12, 5, 45, 5 } ;


B. int n{} = { 2, 4, 12, 5, 45, 5 } ;
C. int n{6} = { 2, 4, 12 } ;
D. int n(6) = { 2, 4, 12, 5, 45, 5 } ;

Answer : A

74. Which of these assignments is invalid?

A. short s = 48;
B. float f = 4.3;
C. double d = 4.3;
D. int I = `1`;

Answer : D

75. The correct way to round off a floating number x to an integer value is

A. y = int (x + 0.5)
B. y = (int) (x + 0.5)
C. y = (int) x + 0.5
D. y = (int) ((int)x + 0.5)

Answer : B

76. Which of the following has compilation error in C?

A. int n = 32;
B. char ch = 65;
C. float f = (float) 3.2;
D. None of the above

Answer : D

77. What will be the output of 5.0 / 2?

A. 2
B. 3
C. 0
D. 2.5

Answer : D
78. What is %f, %d, %s and %c?

A. Number Specifier
B. Format Specifier
C. Access Specifier
D. None of the above

Answer : B

79. The statement printf("%c", 100); will print?

A. prints 100
B. print garbage
C. prints ASCII equivalent of 100
D. None of the above

Answer : C

80. int main()

printf("%d%d%d", sizeof(3.14f), sizeof(3.14l));

A. 4160
B. 844
C. 3284
D. None of the above

Answer :A

81. nt main()

int a = 10, b = 25;

a = b++ + a++;

b = ++b + ++a;
printf("%d %d n", a, b);

A. 36 64
B. 35 62
C. 36 63
D. 30 28

Answer :C

83. int main()

char arr[7]="Network";

printf("%s", arr);

return 0;

A. Network
B. N
C. Garbage value
D. Compilation error

Answer :
A

84. int main ()

int x = 20, y = 35;

x = y++ + x++;

y = ++y + ++x;
printf ("%d %d n", x, y);

A. 55 92
B. 56 93
C. 57 94
D. None of the above

Answer :b

85. int main ()

int x = 24, y = 39, z = 45;

z = x + y;

y = z - y;

x = z - y;

printf ("n%d %d %d", x, y, z);

A. 24 39 63
B. 39 24 63
C. 24 39 45
D. 39 24 45

Answer :B

86. int main ()

int a = 5;
float b;

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

printf (" %d", a);

return 0;

A. 65
B. 56
C. 45
D. 54

Answer :C

87. int main() {

char c = 'f';

switch (c) {

default: printf("unknown colour ");

case 'r': case 'R': printf("Red ");

case 'g': case 'G': printf("Green "); break;

case 'b': case 'B': printf("Blue");

A. Red Green Blue


B. Error
C. Green unknown colour Red
D. unknown colour Red Green

Answer :D
88. int main() {

int x = 1;

while(x = 0)

printf("hello");

A. hello
B. No output
C. Infinite time hello display
D. Error in code

Answer :B

89. void main()

int a = 1, b=2, c=3;

if(a,b,c)

printf("EXAM");

A. EXAM
B. No Output
C. Run time error
D. None of the above

Answer :A
90. void main()

printf("%d", printf("computer science"));

A. computer science16
B. 16computer science
C. computer science
D. computer science18

Answer :A

91. Which is the right way to declare constant in C?

A. int constant var =10;


B. int const var = 10;
C. const int var = 10;
D. B & C Both

Answer : D

92. The statement print f ("%d", 10 ? 0 ? 5 : 1 : 12); will print?

A. 10
B. 0
C. 12
D. 1

Answer : D

93. The correct way to round off a floating number x to an integer value is

A. y = int (x + 0.5)
B. y = (int) (x + 0.5)
C. y = (int) x + 0.5
D. y = (int) ((int)x + 0.5)

Answer : B

94.
Which of the following is the correct order of evaluation for the below expression?
z = x + y * z / 4 % 2 - 1
A. */%+-=

B. = * / % + -

C. / * % - + =

D. * % / - + =

Answer: Option A
Explanation:
C uses left associativity for evaluating expressions to break a tie between two operators having
same precedence.

95. For 16-bit compiler allowable range for integer constants is ______ ?

A. -3.4e38 to 3.4e38
B. -32767 to 32768
C. -32768 to 32767
D. -32668 to 32667

Answer : C

96.
int main()
{
int main = 56;
printf("%d", main);
return 0;
}

A)Compiler Error
b) Depends on the compiler
c) 56
d) none of above

Answer: c

97.

void main()
{
int i, j;
for(i=0,j=0;i<10,j<20;i++,j++){
printf("i=%d \t j=%d\n", i, j);
}
}
a) print i and j till 19
b) print i till 9 and j till 19
c) print i and j till 9
d) Runtime error

Answer: a

98.
#include<stdio.h>
int main()
{
int x=35;
printf("%d %d %d",x==35,x=50,x>40);
return 0;
}
a) 1 50 1
b) 0 50 0
c) Runtime error
d) Compile time error

Answer: b

99. What is the output of this C code?

#include<stdio.h>
int main()
{
int x=1, y=0,z=5;
int a=x&&y||++z;
printf("%d",z++);
}
a) 1
b) 5
c) 6
d) 7
c
Explanation: and operator doesnt operate if second argument is zero. & operator has more
precedence than ||

100. What is the output of this C code?

#define max(a) a
int main()
{
int x = 1;
switch (x)
{
case max(2):
printf("yes\n");
case max(1):
printf("no\n");
break;
}
}
a) yes
b) no
c) Runtime error
d) Compile time error

b
Explanation: Preprocessor just replaces whatever is given such that max(1) is replaced by 1 and
switch case 1 is executed.

Potrebbero piacerti anche