2.unit Bits
2.unit Bits
Answer A
5. Which of the following data type will throw an error on modulus operator (%)
a) Char b) short c) float d) int
Answer C
6. What is the output of this C code?
void main()
{
int a = 20,b=15,c=5,d;
d=a==(b+c);
printf("%d", d);
}
a) 1 b) 40 c) 10 d) 5
Answer A
7. What is the type of below assignment expression if x is of type float and y is of type int?
y=x+y;
a) Int b) double c) There is no type for assignment expression d) float
Answer A
8. For c=2 what will be the value of c after c<<=1
a) C=1 b)c=2 c) c=3 d) c=4
Answer D
9. What is the output of this C code?
void main()
{
int k=8;
int m=7;
int z=k<m?k=m:m++;
printf(“%d”,z);
}
a) Runtime error b) 7 c) 8 d) Depends on the compiler
b) Answer B
10. Which operator produces the 1’s complement of the given binary value
Answer: 1234.12
12. What will be the output?
void main ( )
{
printf(“%d”,5<10 );
}
Answer: 1
13. The output of the below code is
#include<stdio.h>
void main()
{
int x=0;
if(x==0)
printf(“Hai\t”);
else
printf(“Hello\t”);
printf(“Welcome\t”);
}
Answer: Hai Hello
14. The output of the below code is
void main()
{
int x=5;
if(x<1);
printf(“Hello”);
}
Answer: Hello
15. The output of the below code is
void main()
{
int i;
for (i =1;i <=10; i++)
{
if (i==5)
{
break;
}
printf("Hi \n");
}
}
Answer: Hi is printed 4 times
16. The output of the below code is
void main()
{
int i = 0;
if (i == 0)
{
printf("Hello");
continue;
}
}