Variables and Arithmetic
Programming
This program demonstrates variable declaration and basic arithmetic operations in C++.
Implementation
#include <iostream>
int main() {
int a = 10, b = 5;
std::cout << "a: " << a << std::endl;
std::cout << "b: " << b << std::endl;
std::cout << "Sum: " << a + b << std::endl;
std::cout << "Difference: " << a - b << std::endl;
std::cout << "Product: " << a * b << std::endl;
std::cout << "Quotient: " << a / b << std::endl;
return 0;
} Key Concepts
- Variable Declaration:
int a = 10, b = 5;declares and initializes integer variables - Arithmetic Operators:
+,-,*,/for addition, subtraction, multiplication, and division - Output: Multiple values can be chained with
<<
Output
a: 10
b: 5
Sum: 15
Difference: 5
Product: 50
Quotient: 2