Expressions Questions and Answers

Practice Mode
Showing 10 of 26 questions
Q1
Which of the following is the correct order of evaluation for the below expression? z = x + y * z / 4 % 2 - 1
  • A * / % + - =
  • B = * / % + -
  • C / * % - + =
  • D * % / - + =
Answer: Option A
Q2
Which of the following correctly shows the hierarchy of arithmetic operations in C?
  • A / + * -
  • B * - / +
  • C + - / *
  • D / * + -
Answer: Option D
Q3
Which of the following is the correct usage of conditional operators used in C?
  • A a>b ? c=30 : c=40;
  • B a>b ? c=30;
  • C max = a>b ? a>c?a:c:b>c?b:c
  • D return (a>b)?(a:b)
Answer: Option C
Q4
Which of the following is the correct order if calling functions in the below code? a = f1(23, 14) * f2(12/4) + f3();
  • A f1, f2, f3
  • B f3, f2, f1
  • C Order may vary from compiler to compiler
  • D None of above
Answer: Option C
Q5
Which of the following are unary operators in C? 1.     ! 2.     sizeof 3.     ~ 4.     &&
  • A 1, 2
  • B 1, 3
  • C 2, 4
  • D 1, 2, 3
Answer: Option D
Q6
 In which order do the following gets evaluated Relational Arithmetic Logical Assignment
  • A 2134
  • B 1234
  • C 4321
  • D 3214
Answer: Option A
Q7
What is the result of the expression: 5 + 3 * 2?
  • A 16
  • B 11
  • C 13
  • D 10
Answer: Option B
Explanation: Multiplication has higher precedence than addition, so 3*2=6, then 5+6=11.
Q8
Which of the following is a valid C identifier?
  • A 2var
  • B var_name
  • C var-name
  • D var name
Answer: Option B
Explanation: C identifiers must start with a letter or underscore, and contain only letters, digits, or underscores.
Q9
What is the value of the expression: 10 / 3?
  • A 3
  • B 3.333
  • C 3.0
  • D 4
Answer: Option A
Explanation: Integer division truncates the decimal part in C.
Q10
What does the expression: 7 % 2 evaluate to?
  • A 1
  • B 3
  • C 0
  • D 2
Answer: Option A
Explanation: Modulo operator gives the remainder after division.
Questions and Answers for Competitive Exams Various Entrance Test