# C Programming | Operators and Expressions – C Programming MCQ Questions and Answers

## Latest C Program - Operators and Expressions MCQ quiz section | Questions and answer with Solution | Jobvision.in

Dear Student, welcome to C Program - Operators and Expressions quiz section. Are you are preparing for competitive exams, candidate should prepared C Program - Operators and Expressions MCQ Questions and answer. Here you can practice all the latest C Program - Operators and Expressions MCQ with Explanations questions and answers for free. Along with answers you can also find detailed solutions for all C Program - Operators and Expressions questions. These aptitude questions will help you to crack competitive exams such as IT written exams, government exams, bank exams, entrance exams etc.

1 Which of the following operator takes only integer operands?
Solution: Two integers are taken to be input
2 In an expression involving || operator, evaluation

• Will be stopped if one of its components evaluates to false
• Will be stopped if one of its components evaluates to true
• Takes place from right to left
• Takes place from left to right

Solution: No explanation is given for this question
3 Determine output:

``void main(){   int i=0, j=1, k=2, m;   m = i++ || j++ || k++;   printf(%d %d %d %d, m, i, j, k);}``

Solution:
• In an expression involving || operator, evaluation takes place from left to right and will be stopped if one of its components evaluates to true(a non zero value).
• So in the given expression m = i++ || j++ || k++.
It will be stop at j and assign the current value of j in m.
therefore m = 1 , i = 1, j = 2 and k = 2 (since k++ will not encounter. so its value remain 2)
4 Determine output:

``void main(){  int c = - -2;   printf(c=%d, c); }``

Solution:

Here unary minus (or negation) operator is used twice. Same maths rules applies, ie. minus * minus = plus.
Note: However you cannot give like --2. Because -- operator can only be applied to variables as a decrement operator (eg., i--). 2 is a constant and not a variable.

5 Determine output:

``void main(){  int i=10;  i = !i>14;  printf(i=%d, i); }``

Solution:

In the expression !i>14 , NOT (!) operator has more precedence than ' >' symbol. ! is a unary logical operator. !i (!10) is 0 (not of true is false). 0>14 is false (zero).

6 In C programming language, which of the following type of operators have the highest precedence
Solution: No explanation is given for this question
7 What will be the output of the following program?

``void main(){ int a, b, c, d; a = 3; b = 5; c = a, b; d = (a, b);printf(c=%d d=%d, c, d);} ``

Solution: The comma operator evaluates both of its operands and produces the value of the second. It also has lower precedence than assignment. Hence c = a, b is equivalent to c = a, while d = (a, b) is equivalent to d = b.
8 Which of the following comments about the ++ operator are correct?
Solution: No explanation is given for this question
9 What will be the output of this program on an implementation where int occupies 2 bytes?

``#include <stdio.h>void main(){    int i = 3;    int j;    j = sizeof(++i + ++i);    printf(i=%d j=%d, i, j);}``

Solution:

Evaluating ++i + ++i would produce undefined behavior, but the operand of sizeof is not evaluated, so i remains 3 throughout the program. The type of the expression (int) is reduced at compile time, and the size of this type (2) is assigned to j.

10 Which operator has the lowest priority?
Solution: See C Operator Precedence Table
11 What will be the output?

``void main(){  int a=10, b=20; char x=1, y=0; if(a,b,x,y){  printf(EXAM);  } }``

Solution: No explanation is given for this question
12 What number will z in the sample code given below?

``int z, x=5, y= -10, a=4, b=2;z = x++ - --y*b/a;``

Solution:

According to precedence table execution of the given operators are as follows:
1. x++(Postfix operator) i.e x will become 5
2. y--(Prefix operator) i.e y will become -11
3. * and / have same priority so they will be executed according to their associativity i.e left to right. So, *(Multiplication) will execute first and then /(division).
4. -(Subtraction)

So the complete expression would be
5 - (-11)*2/4 = 5 - (-22)/4 = 5 - (-5) = 5 + 5 = 10.

13 What is the output of the following statements?

``int i = 0;printf(%d %d, i, i++);``

Solution:

Since the evaluation is from right to left.
So when the print statement execute value of i = 0
Since its execute from right to left when i++ will be execute first and print value 0 (since its post increment ) and after printing 0 value of i become 1.
So it its prints for 1 for next i.

14 What is the output of the following statements?

``int b=15, c=5, d=8, e=8, a;a = b>c ? c>d ? 12 : d>e ? 13 : 14 : 15;printf(%d, a);``

Solution:

Expression
a = b>c ? c>d ? 12 : d>e ? 13 : 14 : 15;
can be rewritten as 15 What will be the output of the following code fragment?

``void main(){ printf(%x,-1<<4);}``

Solution:

-1 will be represented in binary form as:
1111 1111 1111 1111

Now -1<<4 means 1 is Shifted towards left by 4 positions, hence it becomes:
1111 1111 1111 0000 in hexadecimal form - fff0.

16 Find the output of the following program Solution: 17 Find the output of the following program Solution:

Since the second condition is false so, further conditions will not be checked, it will be skipped.

18 Determine output of the following program code Solution: No explanation is given for this question
19 Choose the correct output for the following program Solution: For any comma separated expression the outcome is the right most part.
20 Consider the following program fragment, and choose the correct one

``void main(){  int a, b = 2, c;  a = 2 * (b++);  c = 2 * (++b);}``

Solution: No explanation is given for this question
21 Which operator from the following has the lowest priority?
Solution: C Operator Precedence Table
22

Identify the correct output of the following code: Solution: 23 Given b=110 and c=20, what is the value of 'a' after execution of the expression a=b-=c*=5?
Solution: As the expression is evaluated from right to left.
24 what will be the output when following code is executed?

``void main(){  int a=10, b;  b = a++ + ++a;  printf(%d %d %d %d, b, a++, a, ++a);}``

``void main(){int c = - -2; printf(c=%d, c);}``