Q1. The following is a program
#include<stdio.h>
main()
{
int x=0;
while(x<=10)
for( ; ; )
if( ++ x%10 = =0)
break;
printf(“x = %d”, x);
}
What will be the output of the above program?
A) Will print x = 10
B) Will give compilation error
C) Will give runtime error
D) Will print x = 20
Q2. Consider the following variable declaration
Union x
{
int i;
float f;
char c;
}y;
if the size of i, f and c are 2 bytes, 4 bytes and 1 byte respectively then the size of the variable y is:-
A) 1 byte
B) 2 bytes
C) 4 bytes
D) 7 bytes
Q3. Pick up the odd one out from the following
A) x=x–1
B) x-=1
C) x--
D) x=-1
Q4. What is the value of ‘average’ after the following program is executed?
main()
{
int sum, index;
float average;
sum = 0;
for( ; ; )
{
sum = sum + index;
++ index;
if (sum > = 100) break;
}
average = sum / index;
}
A) 91/13
B) 91/14
C) 105/14
D) 105/15
Q5. Suppose i, j, k are integer variables with values 1, 2, 3 respectively. What is the value of the following expression?
! (( j + k ) > (i + 5 ))
A) 6
B) 5
C) 1
D) 0
Q6. If a = -11 and b = -3. What is the value of a % b?
A) -3
B) -2
C) 2
D) 3
Q7. If c is a variable initialized to 1, how many times will the following loop be executed?
while(( c > 0 && (c < 60))
{
c++;
}
A) 61
B) 60
C) 59
D) 1
Q8. Which one of the following describes correctly a static variable?
A) This cannot be initialized.
B) This is initialized once at the commencement of execution and cannot be changed at run time.
C) This retains its value through the life of the program.
D) This is same as an automatic variable but is placed at the head of a program.
Q9. What will be the output of the following program?
main()
{
int a, *ptr, b, c;
a = 25;
ptr = &a;
b = a + 30;
c = *ptr;
printf(“%d %d %d”, a, b, c);
}
A) 25, 25, 25
B) 25, 55, 25
C) 25, 55, 25
D) None of the above
Q10. If a = 0×aa and b = a << 1 then which of the following is true
A) b=a
B) b = 2a
C) a = 2b
D) b=a-1