Wednesday, 8 July 2015

Operator And There Use

In a C++ program we use five basic MATHEMATICS OPERATORS 
+     for addition
-     for subtraction
*    for multiplication 
/     for Division 
%   for finding the remainder 

HERE IS Examples OF THESE OPERATORS IN Program

Use of " + " OPERATOR

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
    int x,y;
    x=25;
    y=10;
    cout<<"Plz enter First Number ";
    cin>>x;
    cout<<"Plz Enter second Number ";
    cin>>y;
    cout<<"The sum of both number is = "<<x+y;
    getch();
}

OUTPUT

USE OF " - " OPERATOR

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
    int x,y;
    cout<<"Plz enter First Number ";
    cin>>x;
    cout<<"Plz Enter second Number ";
    cin>>y;
    cout<<"The Answer  of both number by subtracting is = "<<x-y;
    getch();
}

OUTPUT


USE OF " * " OPERATOR

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
    int x,y;
    cout<<"Plz enter First Number ";
    cin>>x;
    cout<<"Plz Enter second Number ";
    cin>>y;
    cout<<"The Answer by Multiplying both number is = "<<x*y;
    getch();
}


OUTPUT

USE OF " / " OPERATOR

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
    int x,y;
    cout<<"Plz enter First Number ";
    cin>>x;
    cout<<"Plz Enter second Number ";
    cin>>y;
    cout<<"The Answer by Dividing both number is = "<<x/y;
    getch();
}

OUTPUT

USE OF " % " OPERATOR

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
    int x,y;
    cout<<"Plz enter First Number ";
    cin>>x;
    cout<<"Plz Enter second Number ";
    cin>>y;
    cout<<"The Remainder of both number is = "<<x%y;
    getch();
}

OUTPUT 

In the same way we can use one or more operators at same time

USE OF ALL OPERATOR IN A PROGRAM

#include<iostream.h>
#include<conio.h>
using namespace std;
int main()
{
    int x,y;
    cout<<"Plz enter First Number ";
    cin>>x;
    cout<<"Plz Enter second Number ";
    cin>>y;
    cout<<"The sum of both number is = "<<x+y<<"\n";
    cout<<"The Answer  of both number by subtracting is = "<<x-y<<"\n";
    cout<<"The Answer by Multiplying both number is = "<<x*y<<"\n";
    cout<<"The Answer by Dividing both number is = "<<x/y<<"\n";
    cout<<"The Remainder of both number is = "<<x%y;
    getch();
}

OUTPUT

QUESTION???

Write a program which take five numbers from user and in return shows the average of the numbers???

No comments:

Post a Comment