Arithmetic Operators in C++ | Types of Arithmetic operators in C++

Arithmetic Operators in C++

Preview

Arithmetic Operators in C++ | Types of Arithmetic operators in C++



Arithmetic Operators in C++

Arithmetic Operators in C++ can do mathematical calculations on numeric values that may exist in the form of variables or constants. Different arithmetic operators in C++ are:

i. +

+ is called Addition operator.  It can add numeric values in C++.

Example: 1+4=5

ii. –

– (hyphen) is called subtraction.  It can subtract one numeric value from another numeric value.

Example: 4-3=1

iii. *

* (Asterisk) is also called multiplication operator. It can multiply numeric values.

Example: 4*3=12

iv. /

/ (Forward Slash) is also known as Division operator. It can divide one numeric value by another numeric value.

Example: 10/3=3

v. % 

% (Percentage Symbol) is known as modulus operator. It gives remainder after dividing one numeric value by another numeric value.

Example 10%4=2

//Program to demonstrate the use of arithmetic operators

#include<iostream> 
using namespace std;
int main()
{
int a,b,c;
a=10;
b=3;
c=a+b;
cout<<c;
c=a-b;
cout<<”\n”<<c;
c=a*b;
cout<<”\n”<<c;
c=a/b;
cout<<”\n”<<c;
c=a%b;
cout<<”\n”<<c;
return 0;
}

Output

13
7
30
3
1



Spread the love
Lesson tags: Addition in C++, Arithmetic Operators in C, Division in C++, modulus operator in C++, Multiplication in C++, Subtraction in C++, Types of Arithmetic operators in C++
Back to: C++ Programming Notes
Spread the love