Infolinks - Earn Easy Money

Saturday, April 4, 2015

C++ program to design a calculator with operation choice for user.

#include <iostream>
#include <conio.h>
using namespace std ;
int main ( )
{
int a ;
do
 {
cout <<" rehanprogrammer.blogspot.com \n " ;

cout <<" \n Enter 1 for Addition \n " ;
cout <<" Enter 2 for Subtraction \n ";
cout <<" Enter 3 for Multiplicatin \n ";
cout <<" Enter 4 for Division \n ";
cout <<" Enter 5 to exit the program \n ";
cout <<" \n Now Enter your desired Operation ";
cin >> a ;
switch ( a )
{
case 1:
int s , d ;
 cout <<" Enter the first value :  \n";
 cin >> s ;
 cout <<" Enter the Second value : \n ";
 cin >> d ;
 cout <<" Addition of two numbers is " << s+d << endl ;
break ;
 case 2:

 cout <<" Enter the first value :  \n";
 cin >> s ;
 cout <<" Enter the Second value : \n ";
 cin >> d ;
 cout <<" Subtraction of two numbers is " << s-d << endl ;
break ;
 case 3:

 cout <<" Enter the first value :  \n";
 cin >> s ;
 cout <<" Enter the Second value : \n ";
 cin >> d ;
 cout <<" Multiplication of two numbers is " << s*d << endl ;
break ;
 case 4:

 cout <<" Enter the first value :  \n";
 cin >> s ;
 cout <<" Enter the Second value : \n ";
 cin >> d ;
 cout <<" Division of two numbers is " << s/d << endl ;
break ;
}
} while(a!=5) ;
return 0 ;
}

No comments:

Post a Comment

Must drop your comments about post.