1.  Assume that i,j and k are integer variables and their values are 8, 5 and 0 respectively. What will be the values of variables i and k after executing the following expression ?
k=(j>5)?(i<5)?i-j:j-i:k-j;
i-=(k)?(i)?(j)?:(i):(k);
What will be the result of execution ?

-3 and 3
3 and -5
3 and -3
-5 and 3

```Answer

Answer: Option  D Explanation:Given that the values of i,j and k are 8, 5 and 0 respectively. The first statement j>5 is not executed
because j=5 and i<5 is also not executed. So the program evaluate k-j, which is, 0-5=-5.
So after execution of first expression the values are 8, 5 and -5 respectively.
In the second statement the values of k, i are non zero. so it is true for both. So the values of i, j
and k are 3, 5 and -5
```

Report

2.  The following program fragment
if (2 < 1)
;
else
x = (2 < 0) ? printf(‘’one’’) : printf(‘’four’’);
printf (‘’%d’’, x);

prints nothing
results in a syntax error
prints four 0
None of the above

```Answer

Answer: Option  D Explanation:here else clause will be executed . Since 2 < 0 is false , 4 will be printed  ```

Report

3.  What's wrong in the following statement, provided k is a variable of type int?
for(k = 2, k <=12, k++)

The increment should always be ++k
The variable must always be the letter i when using a for loop
There should be a semicolon at the end of the statement
The commas should be semicolons

```Answer

Report

4.  The type of the controlling expression of a switch statement cannot be of the type

int
char
short
float

```Answer

Report

5.  What is the output of the following statements ?
for(i=10; i++; i<15)
printf(‘’%d ‘’, i);

10 11 12 13 14
10 11 12 13 14 15
9 10 11 12 13
infinte loop

```Answer