For more discuss and ask question
join this group
Solved By : Tahir
Siddiqui(Mani)
C++ program to Make Simple calculator
//Learn c Language by Tahir Siddiqui(Mani*)
//Virtual university of Pakistan
//tahirsiddiqui190@gmail.com
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double num1,num2;
char opr,redo;
cout<<"Welcome to the calculater program written by Tahir Siddiqui(Mani*)"<<endl;
cout<<"***************************************************************"<<endl;
cout<<endl<<endl<<endl;
do
{
cout<<"pleae enter ur desire opertaion which u like to calculate(+,-,*,/,s)";
cout<<"[s stands for swap]:";
cin>>opr;
cout<<"please enter two # to apply ur requested operation (";
cin>>num1;
cin>>num2;
switch(opr)
{
case'+':
cout<<"the addition of 2 numbers ("<<num1<<","<<num2<<"):";
cout<<num1+num2<<endl;
break;
case'-':
cout<<"the addition of 2 numbers ("<<num1<<","<<num2<<"):";
cout<<num1-num2<<endl;
break;
case'*':
cout<<"the addition of 2 numbers ("<<num1<<","<<num2<<"):";
cout<<num1*num2<<endl;
break;
case'/':
cout<<"the addition of 2 numbers ("<<num1<<","<<num2<<"):";
cout<<num1/num2<<endl;
break;
case's':
cout<<"The swap of two numbers ("<<num1<<","<<num2<<"):";
swap(num1,num2);
cout<<"1stnumber="<<num1<<"and 2nd number="<<num2<<endl<<endl;
break;
default:
cout<<"unknown command"<<endl;
}
cout<<"enter y or Y to continue:";
cin>>redo;
cout<<endl<<endl;
}
while(redo=='y'||redo=='Y');
system("pause");
return 0;
}
Comments
Post a Comment