Expressions Questions

Practice Expressions MCQs with answers and explanations. Page 1 of 2.

Category
C Programming
Topic
Expressions
Page
1 / 2
Mode
Practice

Questions

Open any question to view the answer and explanation.

In C expression evaluation, consider the statement: a = f1(23, 14) * f2(12/4) + f3(); What is the guaranteed order in which the three function calls f1, f2, and f3 are executed?
Open
View answer
Unary operators in C language: from the list 1) ! 2) sizeof 3) ~ 4) &&, which subset consists only of unary operators?
Open
View answer
C operator precedence and associativity: determine the evaluation order by operator for z = x + y * z / 4 % 2 - 1 (from highest to lowest, left-to-right where applicable).
Open
View answer
Hierarchy of arithmetic operations in C: which option correctly places the higher-precedence operators before the lower-precedence ones?
Open
View answer
Across the following operator categories in C—(1) Relational, (2) Arithmetic, (3) Logical, (4) Assignment—what is the correct precedence order from highest to lowest?
Open
View answer
Conditional operator usage in C: which of the following is a correct and idiomatic use of the ternary operator ?:
Open
View answer
In C, evaluate logical expressions and operator precedence. What is the output of the following program? #include<stdio.h> int main() { int i=4, j=-1, k=0, w, x, y, z; w = i || j || k; x = i && j && k; y = i || j && k; z = i && j || k; printf("%d, %d, %d, %d ", w, x, y, z); return 0; }
Open
View answer
C conditional (?:) with character ranges: what does this program print? #include<stdio.h> int main() { char ch; ch = 'A'; printf("The letter is"); printf("%c", ch >= 'A' && ch <= 'Z' ? ch + 'a' - 'A' : ch); printf("Now the letter is"); printf("%c ", ch >= 'A' && ch <= 'Z' ? ch : ch + 'a' - 'A'); return 0; }
Open
View answer
C logical OR (||) evaluation: what does this program output? #include<stdio.h> int main() { int x=12, y=7, z; z = x!=4 || y == 2; printf("z=%d ", z); return 0; }
Open
View answer
C short-circuiting with pre-increment side effects: what does this program print? #include<stdio.h> int main() { int i=-3, j=2, k=0, m; m = ++i && ++j || ++k; printf("%d, %d, %d, %d ", i, j, k, m); return 0; }
Open
View answer
C comma operator in an expression: determine the output. #include<stdio.h> int main() { int i=2; int j = i + (1, 2, 3, 4, 5); printf("%d ", j); return 0; }
Open
View answer
In C programming, what will be the output of the following program (note the nested conditional operator and that only 'num' is printed)? #include<stdio.h> int main() { int k, num = 30; k = (num > 5 ? (num <= 10 ? 100 : 200) : 500); printf("%d ", num); return 0; }
Open
View answer
In C, evaluate short-circuit and precedence: what is the output? #include<stdio.h> int main() { int i = -3, j = 2, k = 0, m; m = ++i || ++j && ++k; printf("%d, %d, %d, %d ", i, j, k, m); return 0; }
Open
View answer
In C, static storage and default initialization: what is printed? #include<stdio.h> int main() { static int a[20]; int i = 0; a[i] = i; printf("%d, %d, %d ", a[0], a[1], i); return 0; }
Open
View answer
Assuming int is 2 bytes, what is printed by this C program (two’s complement typical behavior)? #include<stdio.h> int main() { printf("%x ", -2 << 2); return 0; }
Open
View answer
In C, trace pre-decrement and post-decrement results: what is the output? #include<stdio.h> int main() { int x = 4, y, z; y = --x; z = x--; printf("%d, %d, %d ", x, y, z); return 0; }
Open
View answer
In C, what is the output when assigning with post-increment on the same variable? #include<stdio.h> int main() { int i = 3; i = i++; printf("%d ", i); return 0; }
Open
View answer
In C, evaluate expressions in printf arguments left to right: what prints? #include<stdio.h> int main() { int x = 55; printf("%d, %d, %d ", x <= 55, x = 40, x >= 10); return 0; }
Open
View answer
In C, logical OR produces an integer result: what does this program print? #include<stdio.h> int main() { int a = 100, b = 200, c; c = (a == 100 || b > 200); printf("c=%d ", c); return 0; }
Open
View answer
In C, evaluate logical AND chain with pre-increments: what is the output? #include<stdio.h> int main() { int i = -3, j = 2, k = 0, m; m = ++i && ++j && ++k; printf("%d, %d, %d, %d ", i, j, k, m); return 0; }
Open
View answer

Practice smarter

Solve a few questions daily and revisit weak topics regularly to improve accuracy.