loader image

Operators and Expressions in C – MCQ

Here are the most important Multiple choice questions on Operators and Expressions in C programming. The questions are from the following sections,

  1. Which of the following is a valid expression in C?
    1. int basic_pay = 23000;
    2. int basic_pay = 23,000;
    3. int basic pay = 23000;
    4. int $basic_pay = 23000;
Show Answer

  1. Which of the following arithmetic operator takes only integer operands?
    1. +
    2. /
    3. %
Show Answer

  1. Which of the following operator has the lowest priority?
    1. &&
    2. +
    3. *
    4. !==
Show Answer

  1. Which among the following operator has the highest priority?
    1. Comma operator
    2. Conditional operator
    3. Relational operator
    4. Unary plus operator

  1. Which of the following statement is true?
    1. All arithmetic operators have the same level of precedence.
    2. The modulus operator % can be used only with integers.
    3. A unary expression consists of only one operand with no operators.
    4. The operators <=, >=, and != all enjoy the same level of priority.
Show Answer
  1. What will be the output for the following C code?
    1. 2
    2. 1
    3. 3
    4. Compile-time error
#include <stdio.h>
int main()
{
    int n = 8;
    n = n / 3;
    printf("%d", n);
    return 0;
}
Show Answer

  1. What is the correct order of precedence of arithmetic operators from highest to lowest?
    1. %, *, /, +, –
    2. -, +, *, /, %
    3. %, +, -, *, /
    4. +, – , %, *, /
Show Answer

  1. What will be the output for the following C code?
    1. Value of x is 3
    2. Value of x is 2
    3. Value of x is 1
    4. Compile-time error
#include <stdio.h>
void main()
{
    int y = 4;
    int x = 9 % 2 * 4 / 2;
    printf("Value of x is %d", x);
}
Show Answer

  1. Which of the following is not an arithmetic operation?
    1. a*=5;
    2. a/=5;
    3. a!=5;
    4. a%=5;
Show Answer

  1. What will be the output for the following C code?
    1. 10.6
    2. 10
    3. 11
    4. 16
#include <stdio.h>
int main()
{
    int a = 8;
    double b = 2.6;
    int c;
    c = a + b;
    printf("%d", c);
}
Show Answer
  1. What is the result of a logical or relational expression in C?
    1. 0 or 1
    2. True or false
    3. 0 if false and a positive number if true.
    4. T or F
Show Answer

  1. What will be the output for the following C code?
    1. 23
    2. 15
    3. Undefined behavior
    4. 21
 #include <stdio.h>
 int main()
 {
    int x = 5, y = 2;
    x *= x - y;
    printf("%d", x);
    return 0;
}
Show Answer

  1. What will be the output for the following C code?
    1. 4
    2. 2
    3. 1
    4. Undefined behavior
#include <stdio.h>
int main()
{
    int x = 4, y = 2;
    x /= x / y;
    printf("%d\n", x);
    return 0;
}
Show Answer

  1. What will be the output for the following C code?
    1. Compile-time error
    2. Yes
    3. No
    4. Nothing
#include <stdio.h>
void main()
{
    int x = 0;
    if (x = 0)
        printf("Yes");
    else
        printf("No");
}
Show Answer

  1. What is the use of sizeof() operator?
    1. To get the size of data types or variables in bytes
    2. To get the size of variables only
    3. To get the size of the structure only
    4. None of the above
Show Answer

  1. What is the operator ‘:?’ called?
    1. If-Else operator
    2. Ternary operator
    3. Logical operator
    4. Comparison operator
Show Answer

  1. Which of the following are true regardless of the implementation?
    1. sizeof(int) is not less than sizeof(long)
    2. sizeof(int) equals sizeof(unsigned)
    3. sizeof(double) is not less than sizeof(float)
    4. Both B and C
Show Answer

  1. If y is of integer type then the expressions3 * ( y -8 ) / 9and(y - 8) /9 * 3
    1. must yield the same value
    2. must yield different values
    3. may or may not yield the same value
    4. none of the above
Show Answer
  1. Integer division results in
    1. truncation
    2. rounding
    3. overflow
    4. none of the above
Show Answer

  1. In an expression involving ||operator, evaluation
    1. will be stopped if one of its components evaluates to false
    2. will be stopped if one of its components evaluates to true
    3. takes place from left to right
    4. Both B and C
Show Answer

  1. Implicit type conversion takes place
    1. across an assignment operator.
    2. if an operator has operands of different data types.
    3. Both A and B
    4. None of the above.
Show Answer

  1. Choose the correct statements
    1. Casting refers to implicit type conversion
    2. Coercion refers to implicit type conversion
    3. Casting refers to explicit type conversion
    4. Both B and C
Show Answer

  1. Pick the operators that associate from the left
    1. +
    2. ,
    3. ==
    4. All of above
Show Answer

  1. Pick the operators that associate from the right
    1. ?:
    2. +=
    3. =
    4. All of above
Show Answer

  1. Pick the operators whose meaning is context-dependent.
    1. *
    2. #
    3. &
    4. All of above
Show Answer
  1. x -= y + 1;means
    1. x = x – y + 1
    2. x = -x – y – 1
    3. x = -x + y + 1
    4. x = x – y – 1
Show Answer

  1. Which of the following comments about the ++ operator are correct?
    1. It is a unary operator
    2. The operand can come before or after the operator
    3. It cannot be applied to an expression
    4. All of above
Show Answer

  1. The expression 4 + 6 / 3 * 2 - 2 + 7 % 3evaluates to
    1. 3
    2. 4
    3. 6
    4. 7
Show Answer

  1. If a=5 and b=2 then printf("%d", a+++b); will?
    1. results in a syntax error
    2. print 8
    3. print 10
    4. None of the above
Show Answer

  1. The statement printf("%d", (a++)); will print
    1. the current value of a
    2. the value of a + 1
    3. an error message
    4. garbage
Show Answer

  1. The statement printf("%d", ++5); will print
    1. 5
    2. 6
    3. an error message
    4. garbage
Show Answer

  1. The statement printf("%d", sizeof("")); will print
    1. 0
    2. 1
    3. an error message
    4. garbage value
Show Answer

  1. The ascending order of precedence of the bit-wise operators &, ^, and | is
    1. & ^ |
    2. ^ & |
    3. | ^ &
    4. & | ^
Show Answer

Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Kumudha

for the last question the order of precedence is &^| but in answer &|^ how it will come?

Scroll to Top