/****************************************
Program to calculate two numbers
13/12/11 12:39
*****************************************/
// preprocesser directive
# include <iostream>
# include <conio.h>
using namespace std ;
int main ()
{
// Locaal declaration
double num1 = 0.0,
num2 = 0.0,
ans = 0.0;
int choice = 0 ,
press = 0;
while ( press = 'n' )
{
system ("CLS") ;
cout << "\nPlease Enter first number : " ;
cin >> num1 ;
cout << endl << "Please Enter Second number: " ;
cin >> num2 ;
cout << endl ;
cout << " Please enter \n 1 for Addition \n 2 for Substraction \n 3 for Multiplication \n 4 for Division \n\n " ;
cout << " Please Enter your choice from one to four : " ;
cin >> choice ;
cout << endl ;
switch ( choice )
{
case 1 :
ans = num1 + num2 ;
cout << " We sum these two numbers and answer is : " << ans ;
cout << "\n Press any key to continue" ;
getch ( );
break ;
case 2 :
ans = num1 - num2 ;
cout << " We Subtract these two numbers and answer is : " << ans ;
cout << "\n Press any key to continue" ;
getch ( );
break ;
case 3 :
ans = num1 * num2 ;
cout << " We Multiply these two numbers and answer is : " << ans ;
cout << "\n Press any key to continue" ;
getch ( );
break ;
case 4 :
ans = num1 / num2 ;
cout << " We Divide these two numbers and answer is : " << ans ;
cout << "\n Press any key to continue" ;
getch ( );
break ;
default :
cout << " You Enter Invelid Choice" ;
cout << "\n Press any key to continue" ;
getch ( );
}// end of switch
}// end of while loop
cout << "\n Press any key" ;
getch ( );
system ("CLS");
cout << "\n\n\n\n\n\n\n\n\n Created By:Mohammad Hussnain Imtiaz" ;
getch ( ) ;
return 0 ;
}
No comments:
Post a Comment