Here is a simple way to Perform basic calculation in C++.
The calculations will be performed between two values Provided by the user.
Code:
# include <iostream.h>
# include <conio.h>
void main()
{
clrscr(); //Used to clear screen
float a,b,c,d,e; //Use float as the results can be in Decomals.
cout<<"Enter the first value"<<endl; //You can change this statement
cin>>a;
cout<<"Enter the second value"<<endl;
cin>>b;
clrscr();
cout<<"Addition of two values:"<<a+b<<endl; //First value + second value
cout<<"Difference of Two values:"<<a-b<<endl; //First value - second value
cout<<"Product of two values:"<<a*b<<endl; //First value * second value
cout<<"Division of two values:"<<a/b<<endl; //First value / second value . You can also perform more calculation by changing the Arithmatic operators.
getch();
}
That's all. Hope this helped you.
Bookmarks