C++ - Arithmetic Operators
Overview
Estimated time: 20–30 minutes
Perform math using arithmetic operators and understand integer division vs floating division.
Learning Objectives
- Use + - * / % correctly with ints and doubles.
- Understand prefix vs postfix increment.
Prerequisites
Examples
int a=7/2; // 3
double b=7.0/2; // 3.5
int x=0; int y = x++; // y=0, x=1
Common Pitfalls
- Integer division truncation; cast to double for floating.