Skip to main content

C++ program to MAke Simple calculator



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

Popular posts from this blog

CS401 Assignment#1 Solution Spring 2018

Assignment No. 1 Graded Semester Spring 2018 Computer Architecture and Assembly Language Programming– CS401 Total Marks: 15 Due Date: 10/05/2018 Question: 1                                                                                                                                        [15...

MGT 602 Quiz #1 Solve

GT-602 Solved Quiz # 1 Question # 1 of 15 ( Start time: 11:15:51 AM )   Total Marks: 1   Government can help in forming new venture by providing:   Select correct option:     Finance   Technology   Infrastructure   Subsidiaries Question # 2 of 15 ( Start time: 11:16:50 AM )   Total Marks: 1   The entrepreneur was distinguished from capital provider in:   Select correct option:     18th century   17th century   19th and 20th century   Middle ages