Basic Arithematic operations in C++
There are 5 basic arithematic operations in C++:
+
: add-
: subtract*
: multiply/
: divide. Note: The second operand should not be zero and if both the operands are int then answer will rounded down to an integer , for decimal covert one of them to float.%
:this gives the remainder. Note: The second operand should not be zero.
#include<iostream>
using namespace std;
int main()
{
int a,b;
cout<<"enter a and b:\n";
cin>>a>>b;
cout<<"a+b="<<a+b<<"\n";
cout<<"a-b="<<a-b<<"\n";
cout<<"axb="<<a*b<<"\n";
cout<<"a/b="<<a/b<<"\n";
cout<<"a%b="<<a%b;
return 0;
}
OUTPUT: