C++ Program To Demonstrate Arithmetic Operators
Write C++ Code to Demonstrate Arithmetic Operators
// Write C++ program to demonstrate various arithmetic operation #include <bits/stdc++.h> using namespace std; int main() { int a = 12; int b = 8; int c ; cout << "The value of Number 1 :--> " << a <<endl; cout << "The value of Number 2 :--> " << b <<endl; c = a + b; cout << a << " + " << b << " = " << c <<endl; c = a - b; cout << a << " - " << b << " = " << c <<endl; c = a * b; cout << a << " * " << b << " = " << c <<endl; float d = a / (float)b; cout << a << " / " << b << " = " << d <<endl; c = a % b; cout << a << " % " << b << " = " << c <<endl; c = a + 1; cout << a << " + 1 = " << c <<endl; c = a - 1; cout << a << " - 1 = " << c <<endl; return 0; }
Output:
The value of Number 1 :--> 12
The value of Number 2 :--> 8
12 + 8 = 20
12 - 8 = 4
12 * 8 = 96
12 / 8 = 1.5
12 % 8 = 4
12 + 1 = 13
12 - 1 = 11