You are on page 1of 3

1. What will be the output of the following code?

#include<stdio.h>
int main()
{
int a = 10, b = 2, c=0;
a = !( c = b == c) && ++b;
c += ~( a + b--);
printf( " %d %d %d", b, c, a);
return 0;
}

1. The program will print the output 1 3 0


2. The program will print the output 2 4 1
3. The program will results in expression syntax error
4. The program will print the output 2 -5 1
Answers: 4

2. What Will be the Output Of Following Code Snippet?


# include<stdio.h>
int main()
{
int i=032, j=0x20, k, l, m;
int a=10, b=-7,c=2,sum;
k=i|j;
l=i&j;
m=k^l;
printf("%d, %d, %d, %d, %d\n", i, j, k, l, m);
printf("%d, %d, %d, %d\n", a, b, c, sum);
return 0;
}

1. 26, 32, 58, 0, 58 10, -7, 2, 0


2. 32, 50, 50, 32, 18 10, -6, 2, 6
3. 26, 32, 58, 0, 58 10, -6, 2, 6
4. 32, 32, 32, 32, 0 10, -6, 2, 6

Answers :1

3. What is the use of putchar()?

1. To write a character always to stdout


2. To read a character
3. Nothing
4. Both A & B

Answers: 1

4. What will be the output?


#include<stdio.h>
int main()
{
float x = 'a';
char ch=128;
printf("%f", x);
printf("\t%d", ch);
return 0;
}

1. 97.000000 128
2. 97.00 0
3. 97.000000 -128
4. Compile Time Error

Answers: 3

5. What is the output of following program?


#include<stdio.h>
int main()
{
int a=10,i = 20;
char b;
printf(�%d\n�,(sizeof(i-a)+sizeof(b)));
return 0;
}

1. 11
2. 10
3. 5
4. 0

Answers:3

6. What is the output following program


If user input is : 100
#include<stdio.h>
int main()
{
int i ,a;
i = 1 <<3;
printf(�%d�,i>>3);
return 0;
}

1. Garbage
2. 0
3. 100
4. 1

Answers:4

7. Which of the following statement is correct about the code snippet given below?

num = 5;
printf( �%d�, ++num++ );

1. The code will print 5


2. The code will print 6
3. The code will result in L � value required
4. The code will result in R � value required

Answers: 3
8. What will be the output of the following code?
#include<stdio.h>
int main()
{
int a=2, b = 7,res;
int y=10;
res=(y++>9 && y++!=11 && y++>11) && (a=b<4? b<<1 : ++b>4 ? 7>>1 : a);
printf("\n%d %d %d %d",y,a,b,res);
return 0;
}

1. 13 3 6 1
2. 15 2 9 1
3. 12 2 7 0
4. 12 3 8 0

Answers:3

9. What will be the output of following code snippet?


#include<stdio.h>
void main(){
int a,i=4,j=6;
a=- -i+- -i+- -5;

printf("%d %d",a,i);
printf(" %d %d %d %d %d %d %d",i++,i--,++i,--i,i,i+++j,j--);
return ;
}

1. 12 4 5 5 4 5 4 9 5
2. Compile Time Error
3. 13 4 4 5 5 5 5 9 6
4. 13 4 3 6 5 6 5 8 6

Answers: 3

10. Predict the Output?


#include<stdio.h>
int main()
{
int num1=-2;
unsigned int num2=10;
int ans= ~!(num1<num2);
printf("\n ans=%d", ans);
return 0;
}

1. Compile Time error


2. ans=-2
3. ans=-1
4. ans=0

Answers:2

You might also like