cout << 10 + 3; // 13 addition
cout << 10 - 3; // 7 subtraction
cout << 10 * 3; // 30 multiplication
cout << 10 / 3; // 3 integer division (truncates!)
cout << 10.0/3; // 3.333... float division
cout << 10 % 3; // 1 remainder (modulo)
int a = 7, b = 2;
cout << a / b; // 3 (integer, drops decimal)
cout << (double)a / b; // 3.5
x += 5; x -= 2; x *= 3; x /= 4;
x++; ++x; x--; --x;
Write hypotenuse(double a, double b) using the Pythagorean theorem.
Formula: c = sqrt(a*a + b*b). Use #include <cmath>.
Click "Run" to execute your code.