Question 11
What does sizeof(char) evaluate to in standard C?
Detailed Solution
By C standard definition, sizeof(char) is strictly guaranteed to be 1.
What does sizeof(char) evaluate to in standard C?
By C standard definition, sizeof(char) is strictly guaranteed to be 1.
What is the output of the C program?
#include <stdio.h>
int main(void) {
unsigned int u = 10;
int s = -20;
if (u + s > 0)
printf("Greater");
else
printf("Lesser");
return 0;
}In expressions combining signed int and unsigned int, signed int is promoted to unsigned int. -20 converts to a very large positive unsigned integer, making u + s > 0 evaluate to true.
What will be printed by the following code?
#include <stdio.h>
int main(void) {
int a = 5;
printf("%d", a = 10);
return 0;
}An assignment expression (a = 10) evaluates to the assigned value (10), which is passed to printf.
Which of the following is true regarding bitwise XOR operator $(^)$?
Bitwise XOR evaluates to 1 when the corresponding bits of two operands differ, and 0 when they are identical.
What is the output of this code?
#include <stdio.h>
int main(void) {
int i = 2;
int j = i++ + ++i;
printf("%d", j);
return 0;
}Modifying a scalar variable 'i' more than once between consecutive sequence points results in undefined behavior in C.