Posted by: Sourav | August 20, 2012

Basic mathematical operators in c++


#include<iostream>
using namespace std;

int main()
{
    
    int a,b;
    cout<<“Please enter the first number”<<endl;
    cin>>a;
    cout<<“Please enter the first number”<<endl;
    cin>>b;
    
  float result1,result2,result3,result4,result5;
    
    result1=a+b;
    result2=a-b;
    result3=a*b;
    result4=a/b;
    result5=(a%b);
    cout<<a<<” + “<<b<<” = “<<result1<<endl;
       cout<<a<<” – “<<b<<” = “<<result2<<endl;
          cout<<a<<” * “<<b<<” = “<<result3<<endl;
             cout<<a<<” / “<<b<<” = “<<result4<<endl;
                cout<<a<<” % “<<b<<” = “<<result5<<endl;
    
    //cout << “Hello”<<endl;
    return 0;
    
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: