Arithmetic Operators Practice
These five mathematical operators (+
, -
, *
, /
, and %
) serve to carry out various mathematical operations. They work as you expect it to work and they also account for the order of the operation and parentheses. So the multiplication goes first and so on.
main.cpp
1234567#include<iostream> int main() { // Write any math expression you want std::cout << ___ << std::endl; }
The division operator (/
) returns only the integer part of the result, discarding any remainder. For instance, when dividing 10 by 3, the result is 3, not 3.333... To obtain the desired division result with decimals (e.g., 10 / 3 = 3.333), it is necessary for at least one of the operands to be of a double
or float
data type.
main.cpp
1234567#include <iostream> int main() { std::cout << 5 / 2 << std::endl; std::cout << 5. / 2 << std::endl; }
The modulo operator (%
) calculates and returns the remainder resulting from a standard division operation.
main.cpp
123456#include <iostream> int main() { std::cout << 15 % 8 << std::endl; }
Swipe to start coding
- Fill in the blanks (
___
) with the correct arithmetic operators:- Use
-
,*
,/
, and%
where appropriate. - Focus on the context of the calculations to determine the correct operator.
- Use
Solution
solution.cpp
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 4Awesome!
Completion rate improved to 4
Arithmetic Operators Practice
These five mathematical operators (+
, -
, *
, /
, and %
) serve to carry out various mathematical operations. They work as you expect it to work and they also account for the order of the operation and parentheses. So the multiplication goes first and so on.
main.cpp
1234567#include<iostream> int main() { // Write any math expression you want std::cout << ___ << std::endl; }
The division operator (/
) returns only the integer part of the result, discarding any remainder. For instance, when dividing 10 by 3, the result is 3, not 3.333... To obtain the desired division result with decimals (e.g., 10 / 3 = 3.333), it is necessary for at least one of the operands to be of a double
or float
data type.
main.cpp
1234567#include <iostream> int main() { std::cout << 5 / 2 << std::endl; std::cout << 5. / 2 << std::endl; }
The modulo operator (%
) calculates and returns the remainder resulting from a standard division operation.
main.cpp
123456#include <iostream> int main() { std::cout << 15 % 8 << std::endl; }
Swipe to start coding
- Fill in the blanks (
___
) with the correct arithmetic operators:- Use
-
,*
,/
, and%
where appropriate. - Focus on the context of the calculations to determine the correct operator.
- Use
Solution
solution.cpp
Thanks for your feedback!
single
Awesome!
Completion rate improved to 4
Arithmetic Operators Practice
Swipe to show menu
These five mathematical operators (+
, -
, *
, /
, and %
) serve to carry out various mathematical operations. They work as you expect it to work and they also account for the order of the operation and parentheses. So the multiplication goes first and so on.
main.cpp
1234567#include<iostream> int main() { // Write any math expression you want std::cout << ___ << std::endl; }
The division operator (/
) returns only the integer part of the result, discarding any remainder. For instance, when dividing 10 by 3, the result is 3, not 3.333... To obtain the desired division result with decimals (e.g., 10 / 3 = 3.333), it is necessary for at least one of the operands to be of a double
or float
data type.
main.cpp
1234567#include <iostream> int main() { std::cout << 5 / 2 << std::endl; std::cout << 5. / 2 << std::endl; }
The modulo operator (%
) calculates and returns the remainder resulting from a standard division operation.
main.cpp
123456#include <iostream> int main() { std::cout << 15 % 8 << std::endl; }
Swipe to start coding
- Fill in the blanks (
___
) with the correct arithmetic operators:- Use
-
,*
,/
, and%
where appropriate. - Focus on the context of the calculations to determine the correct operator.
- Use
Solution
solution.cpp
Thanks for your feedback!