C Programming Quiz : Arithmetic Operators

Let's test your skills on C Programming Arithmetic Operators. Programming Quiz, C MCQ.

C Programming Quiz : Arithmetic Operators

C Programming Quiz : Arithmetic Operators

1. Choose a correct statement.
int a = 1 + 3 * 5 / 4 - 10;
  • A) 1, 3, 5, 4 and 10 are Operators. +, -, * and / are Operands. = is an increment operator.
  • B) 1, 3, 5, 4 and 10 are Operands. +, -, * and / are Operators. = is decrement operator.
  • C) 1, 3, 5, 4 and 10 are Operands. +, -, * and / are Operators. = is an assignment operator.
  • D) 1, 3, 5, 4 and 10 are Operands. +, -, * and / are Logical Operators. = is an assignment operator.

Answer is C)
Description:
1, 3, 5, 4 and 10 are Operands. +, -, * and / are Operators. = is an assignment operator.

2. Operator % in C Language is called?
  • A) Percentage Operator
  • B) Modulus
  • C) Quotient Operator
  • D) Division

Answer is B)
Description:
Operator % is called Modulus or Modular or Modulo Division operator in C. It gives the reminder of the division.

3. Output of an arithmetic expression with integers and real numbers is ___ by default?
  • A) Real number
  • B) Integer
  • C) Depends on the numbers used in the expression.
  • D) May be A or B

Answer is A)
Description:
Any arithmetic operation with both integers and real numbers yield output as Real number only.

4. Predict the output?
  • A) 8.000000
  • B) 8.0
  • C) 7
  • D) 8

Answer is D)
Description:
You are printing a float variable by type casting to int. So integer is printed.

5. What is the priority of operators *, / and % in C language?
  • A) % > * > /
  • B) * > / > %
  • C) Both % = / , * are same
  • D) All three operators *, / and % are same.

Answer is D)
Description:
Operators Multiplication *, Division / and Modulo Division % are all having the same Priority.

6. Associativity of C Operators *, /, %, +, - and = is?
  • A) Operators *, / and % have Left to Right Associativity. Operators + and - have Left to Right Associativity. Operator = has Right to Left Associativitiy.
  • B) Operators *, / and % have Right to Left Associativity. Operators + and - have Left to Right Associativity. Operator = has Right to Left Associativitiy.
  • C) Operators *, / and % have Right to Left Associativity. Operators + and - have Right to Left Associativity. Operator = has Right to Left Associativitiy.
  • D) None of the above.

Answer is A)
Description:
Operators *, / and % have Right to Left Associativity. Operators + and - have Right to Left Associativity. Operator = has Right to Left Associativitiy.

7. What is the output of the C Program?
  • A) 3
  • B) 5
  • C) 2
  • D) Can not assign an expression to variable at the time of declaration.

Answer is B)
Description:
Assignment Operator = in C language has the least priority. So the right hand side expression is evaluated first and then assigned to the left side variable.

8. What is the Priority among (*, /, %), (+, -) and (=) C Operators?
  • A) (*, /, %) > (+, -) < (=)
  • B) (*, /, %) < (+, -) < (=)
  • C) (*, /, %) > (+, -) > (=)
  • D) (*, /, %) < (+, -) (+, -) == (=)

Answer is C)
Description:
Assignment operator in C has the least priority.

9. Choose a right statement
int a = 10 + 4.867;
  • A) a = 14
  • B) a = 14.867
  • C) a = 10
  • D) compiler error.

Answer is A)
Description:
a is an int variable. So 10+4.867 = 14.867 is truncated to 14 and assigned to a.

10. In division, to get the actual real value, you should specify at least one ________ number.
  • A) float
  • B) real
  • C) integer
  • D) None of the above

Answer is B)
Description:
In division, to get the actual real value, you should specify at least one real number.


Submit your Quiz Question
Submit your quiz question to us, We will feature your quiz question in our blog with your credits.