MCQs
Total Questions : 35
| Page 4 of 4 pages
Answer: Option C. -> 0,0,0
Step 2: int i = 0; here vaiable i is declared as an integer type and initialized to '0'(zero).
Step 3: a[i] = i ; becomes a[0] = 0;
Step 4: printf("%d, %d, %d`setminus`n", a[0], a[1], i);
Here a[0] = 0, a[1] = 0(because all staic variables are initialized to '0') and i = 0.
Step 4: Hence the output is "0, 0, 0".
Step 1: static int a[20]; here variable a is declared as an integer type and static. If a variable is declared as static and it will ne automatically initialized to value '0'(zero).
Step 2: int i = 0; here vaiable i is declared as an integer type and initialized to '0'(zero).
Step 3: a[i] = i ; becomes a[0] = 0;
Step 4: printf("%d, %d, %d`setminus`n", a[0], a[1], i);
Here a[0] = 0, a[1] = 0(because all staic variables are initialized to '0') and i = 0.
Step 4: Hence the output is "0, 0, 0".
Answer: Option D. -> Output may vary from compiler to compiler
The order of evaluation of arguments passed to a function call is unspecified.
Anyhow, we consider ++i, ++i are Right-to-Left associativity. The output of the program is 4, 3.
In TurboC, the output will be 4, 3.
In GCC, the output will be 4, 4.
Answer: Option B. -> no
Answer: Option A. -> 1
Answer: Option D. -> 1,2,3
An operation with only one operand is called unary operation.
Unary operators:
! Logical NOT operator.
~ bitwise NOT operator.
sizeof Size-of operator.
&& Logical AND is a logical operator.
Therefore, 1, 2, 3 are unary operators.