C++ Arithmetic Operators –>

C++ Arithmetic Operators – C++ Arithmetic Operators Performs maths calculations like addition(+), subtraction(-), division(/), multiplication(*) and modulus(%). Arithmetic operators are further divide into ⇒Unary Operators – The operators that act on one operand are referred as unary operators. ⇒Binary Operators – The operators that act upon two operands are referred as Binary operators.

Arithmetic Operators Types Symbol Name Example Comments
Unary Operators + Unary Plus a=5,a=-4 +a means +5 +a means -4
Unary minus a=5,a=-4 -a means -5 -a means 4
Binary Operators + Addition 7+8=15 Adds values of its two operands
Subtraction 6-5=1 5-6=-1 Subtracts value of right operand from value of left operand
/ Division 80/8=10 Divides value of left operand with value of right operand
* Multiplication 5*3=15 Multiplies the values of both operands
% Modulus or Remainder 10%5=0 8%5=3 3%5=3 Divides the two operands and gives the remainder resulting.
  Example of C++ program for Arithmetic Operators –
#include <iostream.h>
int main ()
   {
   clrscr();
   int a = 10, b = 5;
   cout<<"value of a = "<<a<<"\nand value of b = "<<b;
   cout<<"\nAddition(+) Arithmetic op. will result in = "<<a+b;
   cout<<"\nSubtraction(-) Arithmetic op. will result in = "<<a-b;
   cout<<"\nDivision(/) Arithmetic op. will result in = "<<a/b;
   cout<<"\nMultiplication(*) Arithmetic op. will result in = "<<a*b;
   cout<<"\nModulus(%) Arithmetic operator will result in = "<<a%b;
   return 0;
   }
Output :
value of a = 10
and value of b = 5
Addition(+) Arithmetic op. will result in = 15
Subtraction(-) Arithmetic op. will result in = 5
Division(/) Arithmetic op. will result in = 2
Multiplication(*) Arithmetic op. will result in = 50
Modulus(%) Arithmetic operator will result in = 0
]]>

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top