Write a C++program to input two values and print their addition, subtraction, multiplication and division.
Q5. Write a C++ program program to input two values and print their addition, subtraction, multiplication and division.
Solution:
#include<iostream.h> //standard input/output header file
#include<conio.h> //for clrscr()
int main()
{
int a,b,c,d,e,f;
clrscr(); //to clear the screen
cout<<“\n Enter first value: “;
cin>>a;
cout<<“\n Enter second value: “;
cin>>b;
c=a+b;
d=a-b;
e=a*b;
f=a/b;
cout<<“\n There sum is: “<<c;
cout<<“\n There subtraction is: “<<d;
cout<<“\n There multiplication is: “<<e;
cout<<“\n There division is: “<<f;
getch(); //holds the screen until a key is pressed
return 0; //makes the main() finish
}
OUTPUT:
Enter first value: 8
Enter second value: 3
There sum is: 11
There subtraction is: 5
There multiplication is: 24
There division is: 2