Saturday, 28 April 2012

Program Of Arithmetic Operators In C++

#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int a;
                                a=20;      //Assigment
 a+=10; // Assignment Operator    // a= a+10;
 cout<<"ASsigment For Addition="<< a<<endl;

  a-=10; // Assignment Operator    // a= a+10;
   cout<<"ASsigment For Subtraction="<< a<<endl;

   a*=10; // Assignment Operator    // a= a+10;
    cout<<"ASsigment For Multiplication="<< a<<endl;

    a/=10; // Assignment Operator    // a= a+10;
     cout<<"ASsigment For Division="<< a<<endl;


getch();
}
-----------------------------------------

Here are the most common arithmetic operators


*, / and % will be performed before + or - in any expression. Brackets can be used to force a different order of evaluation to this. Where division is performed between two integers, the result will be an integer, with remainder discarded. Modulo reduction is only meaningful between integers. If a program is ever required to divide a number by zero, this will cause an error, usually causing the program to crash.


No comments:

Post a Comment