Subscribe For Free Updates!

We'll not spam mate! We promise.

Sunday, 26 August 2012

Code of Calculator with C++


//Calculator
//Programmer name: Sohail ahmed
//09/03/2010


#include<iostream.h>
#include<conio.h>

int main()
{
clrscr();
float num_1, num_2;
char user;
cout<<"Press 'a' for Addition, 's' for subtraction, 'm' for multiplication, 'd' for divide\n\n";
cout<<"\nEnter your option: ";
cin>>user;

cout<<"\n\nEnter 1st integer: ";
cin>>num_1;
cout<<"\nEnter 2nd integer: ";
cin>>num_2;

if(user=='a')
{
cout<<"\n\nAddition: "<<num_1+num_2;
}
else if(user=='s')
{
cout<<"\n\nSubtraction: "<<num_1-num_2;
}
else if(user=='m')
{
cout<<"\n\nMultiplication: "<<num_1*num_2;
}
else if(user=='d')
{
cout<<"\n\nDivision: "<<num_1/num_2;
}
else
cout<<"\n\nInvalid option!";

getch();
return 0;
}

Socializer Widget By CodingLovers
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments:

Post a Comment