Home Basic Arithematic operations in C++
Post
Cancel

Basic Arithematic operations in C++

There are 5 basic arithematic operations in C++:

  1. +: add
  2. -: subtract
  3. *: multiply
  4. /: 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.
  5. %:this gives the remainder. Note: The second operand should not be zero.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#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:

output

This post is licensed under CC BY 4.0 by the author.

Trending Tags