Question 96
What is the value of 'val' after executing 'int val = (3 + 4, 5 * 2, 8 - 3);'?
Detailed Solution
The comma operator evaluates expressions left-to-right and yields the final value (8 - 3 = 5).
What is the value of 'val' after executing 'int val = (3 + 4, 5 * 2, 8 - 3);'?
The comma operator evaluates expressions left-to-right and yields the final value (8 - 3 = 5).
What is the output of this C code snippet?
#include <stdio.h>
int main(void) {
int a = 10;
int *p = &a;
*p = 25;
printf("%d", a);
return 0;
}Pointer p stores address of variable a. Dereferencing *p = 25 directly overwrites memory location of a to 25.
What is the value of 'res' after evaluating 'int res = 100 >> 3;'?
100 in binary is 1100100_2. Right shift by 3 bits performs integer division by $2^3$ (8): 100 / 8 = 12.
How many elements are in an array declared as 'int matrix[3][4][5];'?
Total elements in a 3D array = 3 * 4 * 5 = 60 elements.
What is the output of the C code?
#include <stdio.h>
int main(void) {
int a = 10, b = 20;
a = a ^ b;
b = a ^ b;
a = a ^ b;
printf("%d", a);
return 0;
}XOR variable swap algorithm swaps values of a and b. 'a' gets original value of 'b', which is 20.