Which of The Following Is Not A Compound Assignment Operator?
Which of The Following Is Not A Compound Assignment Operator?
a) /=
b) +=
c) %=
d) ==
ANSWER: d) ==
Y = 5, X=0;
if (! Y > 10)
X = Y + 3;
else
X = Y + 10;
3. Which of the following statement is correct about the code snippet given
below?
num = 5;
printf( “%d”, ++num++ );
a) ++p
b) P++
c) Both
d) P+1
View Answer / Hide Answer
ANSWER: c) Both
double X; X = ( 2 + 3) * 2 + 3;
a) 10
b) 13
c) 25
d) 28
View Answer / Hide Answer
ANSWER: b) 13
main()
{
int x = 5; y = -10, z;
int a = 4, b = 2;
z = x+++++y * b/a;
}
a) -2
b) 0
c) 1
d) 2
View Answer / Hide Answer
ANSWER: c) 1
a) 4 10
b) 3 11
c) 3 10
d) 4 11
View Answer / Hide Answer
ANSWER: a) 4 10
a) – 2 1
b) 6 5
c) 4 5
d) 5 5
View Answer / Hide Answer
ANSWER: b) 6 5
11. Which of the following statement is correct about the code snippet given
below?
int main()
{
int a = 10, b = 2, c;
a = !( c = c == c) && ++b;
c += ( a + b- -);
printf( “ %d %d %d”, b, c, a);
return 0;
}
12. Which of the following is the better approach to do the operation i = i * 16?
int p = 0, q = 1;
p = q++;
p = ++q;
p = q--;
p = --q;
a) 1 1
b) 0 0
c) 3 2
d) 1 2
View Answer / Hide Answer
ANSWER: a) 1 1
i = 1;
i = ( I< <= 1 % 2)
a) 2
b) 1
c) 0
d) Syntax error
View Answer / Hide Answer
ANSWER: a) 2
15. What is the correct and fully portable way to obtain the most significant byte
of an unsigned integer x?
a) x & 0xFF00
b) x > > 24
c) x > > ( CHAR_BIT * (sizeof(int) - 3))
d) x > > ( CHAR_BIT * (sizeof(int) - 1))
View Answer / Hide Answer
ANSWER: d) x > > ( CHAR_BIT * (sizeof(int) - 1))
a) (x – (x/y))
b) (x – (x/y) * y)
c) (y – (x/y))
d) (y – (x/y) * y)
View Answer / Hide Answer
ANSWER: b) (x – (x/y) * y)
a) 13
b) 19
c) 25
d) 27
View Answer / Hide Answer
ANSWER: c) 25
i = 1;
i < < 1 % 2;
a) 2
b) -2
c) 1
d) 0
View Answer / Hide Answer
ANSWER: a) 2
19. p++ executes faster than p + 1 since
a) P uses registers
b) Single machine instruction required for p++
c) Option a and b
d) None
View Answer / Hide Answer
#include <stdio.h>
void main()
printf("value is = %d",(10++));
a) 10
b) 11
c) 0
d) ERROR
Correct Answer - 4
Error : L-value required
++/-- operator works on variables only.
#include <stdio.h>
void main()
++var;
printf("%c",var);
}
1. B
2. A
3. ERROR
4. 66
Correct Answer - 3
Error : increment of read-only variable 'var'.
++/-- operator works on variables only, we cannot change the value of a const.
#include <stdio.h>
void main()
{
int x=10;
x+=(x++)+(++x)+x;
printf("%d",x);
1. 44
2. 45
3. 46
4. 47
Correct Answer - 2
45
1) expand the expression : x=x+(x++)+(++x)+x;
2) due to pre increment ++x , x will be 11 for this expression.
3) after executing expression x will be 44.
4) finally x will be 45 due to post increment (x++).
Note: the output of pre and post increment based operators may not same on all the
compilers, in GCC Linux compiler output will be 46 and in TurboC output will be
45.
#include <stdio.h>
void main()
{
int a=10,b=2,x=0;
x=a+b*a+10/2*a;
printf("value is =%d",x);
1. valie is =1250
2. value is =80
3. value is =125
4. ERROR
Correct Answer - 2
value is =80
#include <stdio.h>
void main()
{
printf("x= %d",x);
1. x= 60
2. x= 70
3. x= 0
4. x= 1
Correct Answer - 4
x=1
1)(20 || 40) .... both are non zero values, will return 1.
2)(1) && 10 .... both are non zero values, hence output will be 1.
#include <stdio.h>
void main()
{
int x;
x= (printf("AA")||printf("BB"));
printf("%d",x);
printf("\n");
x= (printf("AA")&&printf("BB"));
printf("%d",x);
}
1. AABB1
AABB1
2. 1
1
3. AABB1
AA1
4. AA1
AABB1
Correct Answer - 4
AA1
AABB1
1)printf() return total number of characters, printf("AA") will return 2 hence expression is true
second expression printf("BB") will not execute.
2)in this statement both expressions will execute.