MCQ PORTAL

Back to All Topics

Operators and Expressions

Showing 33 of 33 questions in this topic

Start Practice Mode

Answer Green MarksON

Correct answers are highlighted in green

C015Operators and Expressions • Arithmetic
Most ImportantEasy

Q1.What is the value of the expression 5 / 2 in C?

A
2.5
B
2
Correct answer
C
3
D
2.0
C016Operators and Expressions • Arithmetic
Most ImportantEasy

Q2.What is the value of 5 % 2 in C?

A
1
Correct answer
B
2
C
2.5
D
0
C018Operators and Expressions • Increment/Decrement
Most ImportantMedium

Q3.What is printed? int a = 5; printf("%d", a++);

A
5
Correct answer
B
6
C
4
D
error
C019Operators and Expressions • Increment/Decrement
Most ImportantMedium

Q4.What is printed? int a = 5; printf("%d", ++a);

A
5
B
6
Correct answer
C
4
D
error
C021Operators and Expressions • Logical
Most ImportantEasy

Q5.The logical AND operator in C is written as:

A
&
B
&&
Correct answer
C
AND
D
|
C022Operators and Expressions • Relational
Most ImportantEasy

Q6.What is the result of the expression (5 > 3) in C?

A
1
Correct answer
B
0
C
true
D
5
C025Operators and Expressions • Assignment
Most ImportantEasy

Q7.Which of the following is the ASSIGNMENT operator (not comparison)?

A
==
B
=
Correct answer
C
>=
D
!=
C026Operators and Expressions • Precedence
Most ImportantEasy

Q8.What is the value of a? a = 5 + 3 * 2;

A
16
B
11
Correct answer
C
13
D
10
C028Operators and Expressions • I/O
Most ImportantEasy

Q9.Which format specifier is used for a float value in printf()?

A
%d
B
%f
Correct answer
C
%c
D
%s
C030Operators and Expressions • Escape sequence
Most ImportantEasy

Q10.The escape sequence \n is used to:

A
insert a tab
B
move to a new line
Correct answer
C
insert a null character
D
ring a bell
C104Operators and Expressions • Compound assignment
Most ImportantEasy

Q11.The statement a += 5; is equivalent to:

A
a = 5;
B
a = a + 5;
Correct answer
C
a = a * 5;
D
a = 5 + 5;
C105Operators and Expressions • Logical
Most ImportantEasy

Q12.The logical NOT operator in C is:

A
!
Correct answer
B
&&
C
||
D
~
C110Operators and Expressions • Precedence
Most ImportantMedium

Q13.What is the value of 10 % 3 + 2 in C?

A
2
B
3
Correct answer
C
5
D
1
C111Operators and Expressions • Precedence
Most ImportantEasy

Q14.What is the value of 2 + 3 * 4 - 1 in C?

A
19
B
13
Correct answer
C
20
D
16
C118Operators and Expressions • Relational
Most ImportantEasy

Q15.What is the value of 5 == 5 in C?

A
0
B
1
Correct answer
C
5
D
error
C017Operators and Expressions • Arithmetic
ImportantMedium

Q16.The modulus operator % in C can be used with:

A
only float operands
B
only integer operands
Correct answer
C
both int and float
D
only char
C020Operators and Expressions • Precedence
ImportantMedium

Q17.Which operator has the HIGHEST precedence among the following?

A
+
B
*
Correct answer
C
=
D
||
C023Operators and Expressions • Conditional
ImportantMedium

Q18.The conditional (ternary) operator in C is written as:

A
? :
Correct answer
B
::
C
if..else
D
=>
C024Operators and Expressions • Conditional
ImportantMedium

Q19.What does this assign to x? int x = (3 > 2) ? 10 : 20;

A
10
Correct answer
B
20
C
3
D
2
C027Operators and Expressions • Type conversion
ImportantMedium

Q20.Automatic conversion of a lower data type to a higher one in an expression is called:

A
explicit conversion
B
type casting
C
implicit conversion (promotion)
Correct answer
D
coercion error
C029Operators and Expressions • Escape sequence
ImportantEasy

Q21.The escape sequence \t represents a:

A
newline
B
tab space
Correct answer
C
backspace
D
null character
C106Operators and Expressions • Logical
ImportantMedium

Q22.What is the value of !0 in C?

A
0
B
1
Correct answer
C
-1
D
error
C107Operators and Expressions • Logical
ImportantMedium

Q23.What is the value of !5 in C?

A
5
B
1
C
0
Correct answer
D
-5
C108Operators and Expressions • Logical
ImportantMedium

Q24.What is the value of (5 > 3 && 2 < 1) in C?

A
1
B
0
Correct answer
C
true
D
error
C109Operators and Expressions • Logical
ImportantMedium

Q25.What is the value of (5 > 3 || 2 < 1) in C?

A
0
B
1
Correct answer
C
2
D
error
C112Operators and Expressions • Type conversion
ImportantHard

Q26.What is the value of z? int x = 7, y = 2; float z = x / y;

A
3.5
B
3.0
Correct answer
C
4.0
D
3
C113Operators and Expressions • Type conversion
ImportantHard

Q27.To get the result 3.5 from 7 / 2 in C, you must:

A
use % instead of /
B
make at least one operand a float (e.g. 7.0 / 2)
Correct answer
C
use two int variables
D
add a semicolon
C114Operators and Expressions • Type conversion
ImportantMedium

Q28.What is the value of x? char c = 'A'; int x = c;

A
A
B
0
C
65
Correct answer
D
1
C116Operators and Expressions • Unary
ImportantMedium

Q29.Which of the following is a UNARY operator?

A
%
B
++
Correct answer
C
&&
D
*
C117Operators and Expressions • Assignment
ImportantMedium

Q30.After a = b = 5; what are the values of a and b?

A
a = 5, b = 0
B
a = 0, b = 5
C
both are 5
Correct answer
D
error
C119Operators and Expressions • Relational
ImportantEasy

Q31.What is the value of 5 != 5 in C?

A
1
B
0
Correct answer
C
5
D
error
C031Operators and Expressions • Comma operator
OtherHard

Q32.What is the value of the expression (5, 10, 15) in C?

A
5
B
10
C
15
Correct answer
D
30
C115Operators and Expressions • Associativity
OtherHard

Q33.The associativity of the assignment operator = in C is:

A
left to right
B
right to left
Correct answer
C
top to bottom
D
none