Arithmetic operators are symbols used to perform basic math operations like addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
Click to reveal answer
beginner
What does the modulus operator (%) do in C++?
The modulus operator (%) gives the remainder after dividing one number by another. For example, 7 % 3 equals 1 because 7 divided by 3 leaves a remainder of 1.
Click to reveal answer
intermediate
How does integer division differ from floating-point division in C++?
Integer division divides two integers and discards any decimal part, giving an integer result. Floating-point division divides numbers with decimals and keeps the fractional part.
Click to reveal answer
beginner
What will be the result of this C++ expression: 5 + 3 * 2?
The result is 11 because multiplication (*) has higher priority than addition (+). So, 3 * 2 = 6, then 5 + 6 = 11.
Click to reveal answer
beginner
Can arithmetic operators be used with floating-point numbers in C++?
Yes, arithmetic operators like +, -, *, and / can be used with floating-point numbers (like float or double) to perform math with decimals.
Click to reveal answer
Which operator gives the remainder of a division in C++?
A%
B/
C*
D-
✗ Incorrect
The % operator returns the remainder after division.
What is the result of 10 / 4 in C++ if both are integers?
A3
B2.5
C2
D4
✗ Incorrect
Integer division discards the decimal part, so 10 / 4 equals 2.
Which operator has the highest precedence in this expression: 4 + 5 * 6?
A/
B+
C-
D*
✗ Incorrect
Multiplication (*) has higher precedence than addition (+).
What is the output of 7 % 4 in C++?
A4
B3
C1
D7
✗ Incorrect
7 divided by 4 leaves a remainder of 3.
Can you use the + operator to add two double variables in C++?
AYes
BNo
COnly if they are cast to int
DOnly if they are constants
✗ Incorrect
The + operator works with floating-point types like double.
Explain the difference between integer division and floating-point division in C++.
Think about dividing 7 by 2 using int and double types.
You got /3 concepts.
List all basic arithmetic operators in C++ and give a simple example of each.
Use numbers like 5 and 3 for examples.
You got /6 concepts.
Practice
(1/5)
1. Which arithmetic operator in C++ is used to find the remainder of a division?
easy
A. -
B. /
C. %
D. *
Solution
Step 1: Understand the meaning of each operator
The operator % returns the remainder after division, while / returns the quotient.
Step 2: Identify the operator for remainder
Since remainder is asked, the correct operator is %.
Final Answer:
% -> Option C
Quick Check:
Remainder operator = % [OK]
Hint: Remainder uses % symbol, not division / [OK]
Common Mistakes:
Confusing / with %
Using * for remainder
Using - for remainder
2. Which of the following is the correct syntax to multiply two integers a and b in C++?
easy
A. a * b;
B. a x b;
C. a multiply b;
D. a . b;
Solution
Step 1: Recall multiplication operator syntax
In C++, multiplication uses the asterisk symbol * between operands.
Step 2: Check each option
Only a * b; uses the correct operator and syntax.
Final Answer:
a * b; -> Option A
Quick Check:
Multiplication operator = * [OK]
Hint: Use * for multiplication, not words or symbols [OK]
Common Mistakes:
Using x instead of *
Writing multiply as word
Using dot operator for math
3. What is the output of the following C++ code?
int a = 10, b = 3;
std::cout << a / b << std::endl;
medium
A. 3.33333
B. 3
C. 4
D. Error
Solution
Step 1: Understand integer division in C++
Both a and b are integers, so division truncates decimals.
Step 2: Calculate integer division result
10 divided by 3 is 3.333..., but integer division returns 3.
Final Answer:
3 -> Option B
Quick Check:
Integer division truncates decimals = 3 [OK]
Hint: Integer division drops decimals, result is integer [OK]
Common Mistakes:
Expecting decimal result
Using floating-point division without casting
Thinking output is error
4. Identify the error in this C++ code snippet:
int x = 5;
int y = 2;
int z = x / y.0;
std::cout << z << std::endl;
medium
A. Syntax error due to decimal point in divisor
B. Using floating-point literal with integer division
C. Incorrect variable declaration
D. Missing semicolon
Solution
Step 1: Analyze the divisor y.0
The expression y.0 is invalid syntax in C++ because variables cannot have decimal points.
Step 2: Identify the syntax error
The decimal point after y causes a syntax error; correct would be y * 1.0 or static_cast<double>(y).
Final Answer:
Syntax error due to decimal point in divisor -> Option A
Quick Check:
Variable names cannot have decimal points [OK]
Hint: Variable names can't have dots; causes syntax error [OK]
Common Mistakes:
Thinking y.0 is valid float
Ignoring syntax error
Confusing variable and literal
5. Given int a = 7, b = 4;, which expression correctly calculates the average as a floating-point number in C++?
hard
A. a / b + 2
B. (a + b) / 2
C. a + b / 2
D. (a + b) / 2.0
Solution
Step 1: Understand integer vs floating-point division
Using 2 divides integers, truncating decimals. Using 2.0 forces floating-point division.
Step 2: Evaluate each option
(a + b) / 2 does integer division, result 5. (a + b) / 2.0 divides by 2.0, giving 5.5 as float. Options C and D do not calculate average correctly.
Final Answer:
(a + b) / 2.0 -> Option D
Quick Check:
Use floating-point divisor for decimal average [OK]
Hint: Divide by 2.0 to get decimal average, not integer [OK]
Common Mistakes:
Using integer 2 causing truncation
Wrong operator precedence
Misinterpreting average formula
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.