C Operators and Expressions MCQs: 12 Solved Questions with Explanations

Solve 12 C operators and expressions MCQs from UGC NET, ISRO, Coal India, BPSC and UPPSC papers. Each answer traces the rule, value change, or representation that decides it.

KnowledgeGate Team

Exam prep & CS education

Updated 12 Aug 20268 min read

C operator questions look short, but precedence, side effects, conversions, and representation can change the answer. All 12 questions below are previous-year papers: UGC NET 2013, 2014, 2017 and 2020, ISRO 2014, Coal India 2017 and 2020, UPPSC Polytechnic Lecturer 2018, and BPSC 2024.

Attempt each question before you read its answer. Where the code is short, trace it on paper: writing the value of every variable after each operator settles the question faster than arguing with the options.

1. Operator categories and arithmetic failure points

Identify the operator family first. Arithmetic operators change values, relational operators compare them, and logical operators combine or negate conditions. In division and remainder expressions, solve inside parentheses first and check for a zero divisor.

Question 1 | UGC NET 2020

Given below are two statements :

Statement I : Operators are special symbols that are used to perform calculations, make comparisons and check logical condition.

Statement II : Relational operators are used for arithmetic operations.

In the light of the above statements, choose the correct answer from the options given below :

A. Both Statement I and Statement II are true

B. Both Statement I and Statement II are false

C. Statement I is correct but Statement II is false

D. Statement I is incorrect but Statement II is true

Answer: C

Statement I correctly covers arithmetic, comparison, and logical uses. Statement II is false because <, >, ==, and != compare operands, while +, -, *, /, and % perform arithmetic.

Practise this statement pair, then browse the Coding & DSA courses for more programming fundamentals.

Question 2 | Coal India 2017

Which of the following ‘C’ language arithmetic expressions has logical error?

A. -13 % -5 + 3;

B. 4 / (-10 % -2) / 3;

C. 3 / (-13 % -5) / 3;

D. -5 % 3 / 13;

Answer: B

-10 % -2 = 0, so B attempts 4 / 0, which is invalid. The finite traces are A: -13 % -5 = -3, then -3 + 3 = 0; C: 3 / -3 / 3 = -1 / 3 = 0; and D: -5 % 3 = -2, then -2 / 13 = 0, with integer truncation towards zero.

Try more zero-divisor traps.

Question 3 | UGC NET 2013

The correct way to round off a floating number x to an integer value is

A. y = (int) (x + 0.5)

B. y = int (x + 0.5)

C. y = (int) x + 0.5

D. y = (int) ((int)x + 0.5)

Answer: A

For the intended positive-number case, adding 0.5 and casting rounds to the nearest integer. With x = 7.6, (int)(7.6 + 0.5) = (int)8.1 = 8. This is not a general rounding rule for negative values.

Practise more cast-and-round questions.

2. Prefix, postfix, and side effects without guesswork

Beside every ++, note the value used now and the value stored afterwards. Prefix changes first and contributes the new value. Postfix contributes the old value, then changes it.

Question 4 | UGC NET 2014

What will be the output of the following ‘C’ code ?

main ( )
{
    int x = 128;
    printf ("\n%d", 1 + x ++);
}

A. 128

B. 129

C. 130

D. 131

Answer: B

Postfix x++ supplies 128, so printf receives 1 + 128 = 129. The stored x then becomes 129, but it is not printed again.

Work through more postfix output traces.

Question 5 | UPPSC Polytechnic Lecturer 2018

The program fragment:

int a = 5, b = 2;
printf("%d", a++ + ++b);

What does it print?

A. Prints 7

B. Prints 8

C. Prints 9

D. None of the above

Answer: B

Postfix a++ contributes 5 and leaves a = 6; prefix ++b changes b to 3 and contributes 3. The sum is 5 + 3 = 8, with final values a = 6 and b = 3.

Try more mixed prefix and postfix sums.

Question 6 | Indian Space Research Organization 2014

The following three 'C' language statements is equivalent to which single statement? y=y+1; z=x+y; x=x+1

A. z = x + y + 2;

B. z = (x++) + (++y);

C. z = (x++) + (y++);

D. z = (x++) + (++y) + 1;

Answer: B

Call the starting values x0 and y0. The statements give y = y0 + 1, z = x0 + y0 + 1, and x = x0 + 1; B matches because x++ contributes x0 and ++y contributes y0 + 1.

Practise more statement-to-expression conversions.

Question 7 | Coal India 2020

What is the output/behavior of the following C program?

#include<stdio.h>
int main()
{
    int i = 5;
    printf("%d %d %d", i++, i, ++i);
    return 0;
}

A. 7 6 6

B. 6 7 8

C. Undefined behavior

D. 5 6 7

Answer: C

The arguments modify i multiple times without sequencing and also access it, so C defines no output. Left-to-right or right-to-left tracing is invalid. Update and store each value in a separate statement before calling printf.

Work through more unsequenced modification cases.

3. Bitwise operators, octal values, and powers of two

Convert operands to a fixed representation before applying &, >> or <<. A power of two carries exactly one set bit, so 8 is 1000 in binary; a literal that starts with a zero, such as 0570, is octal and equals 376 in decimal. Number Systems and Base Conversions Explained is a useful refresher on moving between the two.

Question 8 | UGC NET 2017

If X is a binary number which is power of 2, then the value of X & (X – 1) is :

A. 11….11

B. 00…..00

C. 100…..0

D. 000……1

Answer: B

A positive power of two has one set bit. For X = 8 = 1000₂, X - 1 = 7 = 0111₂, so 1000₂ & 0111₂ = 0000₂. Thus X & (X - 1) is zero.

Try more bit-clearing identities.

Question 9 | Indian Space Research Organization 2014

Write the output of the following C program

#include <stdio.h>

int main (void)
{
    int shifty;
    shifty = 0570;
    shifty = shifty >>4;
    shifty = shifty <<6;
    printf("the value of shifty is %o",shifty);
}

A. the value of shifty is 15c0

B. the value of shifty is 4300

C. the value of shifty is 5700

D. the value of shifty is 2700

Answer: D

The leading zero makes 0570 octal, so 0570₈ = 376₁₀. Right-shifting gives 376 >> 4 = 23₁₀ = 027₈, then left-shifting gives 23 << 6 = 1472₁₀ = 2700₈. The %o conversion prints the value of shifty is 2700.

Practise more octal shift traces.

Two worked panels: X & (X-1) clearing the single set bit of 8 to zero, and 0570 octal shifted right by 4 then left by 6 to print 2700.

4. Macro expansion and unevaluated operands

For a macro, substitute the literal argument text before evaluating. For sizeof, first mark whether its operand is unevaluated, then decide whether any assignment or side effect inside it can run.

Question 10 | Indian Space Research Organization 2014

What is the output of the following C program?

#include<stdio.h>
#define SQR(x) (x*x)
int main()
{
    int a;
    int b=4;
    a=SQR(b+2);
    printf("%d\n",a);
    return 0;
}

A. 14

B. 36

C. 18

D. 20

Answer: A

Literal substitution changes SQR(b+2) into (b+2*b+2), not ((b+2)*(b+2)). Multiplication binds first, so b = 4 gives 4 + 2*4 + 2 = 14. A safer definition, #define SQR(x) ((x)*(x)), would give (4+2)*(4+2) = 36 here.

Work through more macro substitution traps.

Question 11 | BPSC 2024

#include <stdio.h>
int main()
{
    int i = 5, j = 10, k = 15;
    printf("%d ", sizeof(k = i + j));
    printf("%d", k);
    return 0;
}

Assume size of an integer as 4 bytes. What is the output of above program?

A. 2 1

B. 4 1

C. 4 15

D. More than one of the above

E. None of the above

Answer: C

Under the stated assumption, sizeof(k = i + j) reports 4 because the expression has type int. Its operand is not evaluated, so the assignment does not run and k remains 15. The calls print 4 15.

Try more sizeof evaluation questions.

5. Formatted numeric output

Treat each conversion specification independently: identify its precision, minimum field width, and notation. Calculate all three renderings before matching the complete option.

Question 12 | Coal India 2017

What is the output when the following segment of ‘C’ code is executed?

void main()
{
    float a = 123.456;
    printf("%.2f, %7.3f, %12e", a, a, a);
}

A. 123.450, 123.4560, 1.234560e+02

B. 123.46, 123.456, 1.234560e+02

C. 123.456000, 123.456, 0.1234560e+03

D. 123.45, 123.4560, 1.234560e+02

Answer: B

%.2f rounds 123.456 to two fractional digits, producing 123.46. %7.3f uses three fractional digits and a minimum width of 7, producing 123.456, while %12e produces 1.234560e+02. The complete output matches option B.

Practise more format specifier outputs.

6. The five-check trap map

Check

Ask before solving

Worked anchor from this set

Operator family

Is this arithmetic, relational, logical, or bitwise?

Relational operators compare; they do not perform arithmetic.

Inner operation

Can a remainder or divisor become zero?

-10 % -2 = 0, so 4 / 0 is invalid.

Side effects

Is one object modified more than once without sequencing?

a++ + ++b uses separate objects and prints 8; i++, i, ++i in one printf is undefined.

Representation

Is the literal decimal, octal, hexadecimal, or binary?

0570₈ >> 4 = 027₈, then 027₈ << 6 = 2700₈.

Evaluation

Is this macro substitution or an unevaluated operand?

SQR(b+2) expands to an expression worth 14; sizeof(k=i+j) leaves k = 15.

Use a 30-second routine: mark the operators, add grouping parentheses by precedence, write the current variable values, convert bases, and only then match an option. For another programming practice collection, continue with the Data Structures MCQs hub.

7. Short version and the next practice step

  • Precedence decides how an expression is grouped.

  • Prefix and postfix decide when a stored value changes and which value enters the expression.

  • Bitwise questions require an explicit representation before any operation.

The C Language course is the direct next step for C concepts, MCQs, and coding practice. If your preparation spans C, C++, Java, Python and placement coding, Mera Placement Hoga is the broader route.