01 - OperatorsWithAnswers
01 - OperatorsWithAnswers
#include <stdio.h>
int main( void )
{
int i = 0X7 + 07 + 7;
return 0;
}
A. 7 + 7 + 7 = 15
7 + 7 + 7 = 25
B. 7 + 7 + 7 = 21
7 + 7 + 7 = 15
C. 7 + 1 + 7 = 15
7 + 7 + 7 = 21
D. 1 + 1 + 7 = 9
7 + 7 + 7 = 21
Answer: A
2.
#include <stdio.h>
int main( void )
{
printf("%d", (sizeof(10.222)*sizeof(10.222f))/sizeof(void) * sizeof(10.222));
return 0;
}
A. 128
B. 256
C. 512
D. 64
Answer: B
3.
Suppose a,b,c are integer variables with values 5,6,7 respectively.
What is the value of expression: !((b+c)>(a+10))
A. 1
B. 6
C. 15
D. 0
Answer: A
4.
What the below statement will print if a=10. printf("%d %d",a, !a++);
A. 10 11
B. 11 0
C. 11 10
D. 0 11
Answer: B
5.
What will be output of following code ?
#include <stdio.h>
int main( void )
{
int x = 1, y = 0, z = 5;
return 0;
}
A. 6
B. 5
C. 0
D. Varies
Answer: A
6.
What will be output of following code ?
#include <stdio.h>
int main( void )
{
int x = 1, y = 0, z = 5;
int a = x && y++ && z++;
printf("y=%d z=%d ", y,z);
return 0;
}
A. y=1 z=7
B. y=1 z=5
C. y=0 z=4
D. y=0 y=0
Answer: B
7.
What will be output of following code ?
#include <stdio.h>
int main( void )
{
int i = 1, j=0;
return 0;
}
A. i=1 j=1
B. i=2 j=0
C. i=1 j=0
D. i=2 j=1
Answer: B
8.
What will be output of following code ?
#include <stdio.h>
int main( void )
{
int i=0, j=1, k=2, m;
return 0;
}
A. 1 1 0 2
B. 1 1 0 3
C. 1 1 2 2
D. 0 1 2 3
E. None of these
Answer: C
9.
What will be output on 64 bit compiler ?
#include <stdio.h>
int main( void )
{
printf("\n%d",sizeof((int) &main)+2);
return 0;
}
A. 8
B. 6
C. 4
D. 10
Answer: B
10.
What will be output of following code on 64 bit Compiler ?
#include <stdio.h>
int main( void )
{
int a = 10;
double d = 10.21;
printf("%d", sizeof(a+d));
return 0;
}
A. 4
B. 16
C. 8
D. 12
Answer: C
11.
What will be printed as the result of the operation below.(gcc compiler)
#include <stdio.h>
int main( void )
{
float x;
x= 0.35 == 3.5/10;
printf("%f", x);
return 0;
}
A. 0.000000
B. 1.000000
C. 1.0
D. 0.0
Answer: B
12.
#include<stdio.h>
int main(void)
{
int t,a=5,b=10,c=15;
return 0;
}
A. 7 8 11 15
B. 6 7 10 14
C. 1 8 10 15
D. 6 18 11 15
Answer : C
13.
What value of c will get printed
#include <stdio.h>
int main(void)
{
int a,b,c;
a=10;
b=20;
c=printf("%d",a)+ ++b;
printf(" %d",c);
return 0;
}
A. 10 23
B. 10 22
C. 10 30
D. Compilation Error
Answer: A
14.
Given the following program fragment
#include <stdio.h>
int main( void )
{
int i, j, k;
i = 3;
j =2*(i++);
k =2*(++i);
return 0;
}
15.
What will be the output ?
#include <stdio.h>
int main( void )
{
if(1++,0--)
{
printf("True");
}
else
{
printf("False");
}
return 0;
}
a = 1, 2, 3;
printf("%d", a);
return 0;
}
A. 3
B. 2
C. 1
D. compile time error
Answer: C