Results 1 to 8 of 8

Thread: Simple calculator using Switch case in C++

  1. #1
    Abidalicu's Avatar
    Abidalicu is offline Senior Member+
    Last Online
    15th August 2017 @ 08:17 PM
    Join Date
    17 Aug 2014
    Location
    Peshawar
    Gender
    Male
    Posts
    83
    Threads
    12
    Credits
    509
    Thanked
    4

    Default Simple calculator using Switch case in C++




    #include<iostream> //Header files

    using namespace std;

    int main() //main Function

    {
    double value1,value2,result; //Assign Variables

    char ooperator; // Character

    cout<<"Please enter first value\n"; //output

    cin>>value1;//input

    cout<<"Enter an operator (mathematical symbol e.g + / * -)\n";

    cin>>ooperator;

    cout<<"Please enter second value\n";

    cin>>value2;

    cout<<"the result is"<<"\n"<<"-------\n";

    switch(ooperator) //switch case
    {

    case '*': //if i enter * it will give me the following result
    {
    result=value1*value2;
    cout<<result;
    break; //if the condition is satisfied it break the program and go to end
    }
    case '+': //if i enter + it will give me the following result
    {
    result=value1+value2;
    cout<<result;
    break;
    }
    case '/': //if i enter / it will give me the following result
    {
    result=value1/value2;
    cout<<result;
    break;
    }
    case '-': //if i enter - it will give me the following result
    {
    result=value1-value2;
    cout<<result;
    break;
    }

    }


    return 0;


    }

  2. #2
    The Rocket is offline Member
    Last Online
    11th May 2015 @ 01:44 PM
    Join Date
    27 Mar 2015
    Age
    23
    Gender
    Male
    Posts
    1,137
    Threads
    82
    Thanked
    96

    Default

    great share with us

  3. #3
    king parvez's Avatar
    king parvez is offline Junior Member
    Last Online
    3rd July 2017 @ 05:43 PM
    Join Date
    12 Jan 2015
    Posts
    5
    Threads
    0
    Credits
    6
    Thanked
    0

    Default

    very nice....

  4. #4
    AHMED612 is offline Junior Member
    Last Online
    23rd July 2016 @ 10:37 PM
    Join Date
    20 Nov 2013
    Gender
    Male
    Posts
    1
    Threads
    0
    Credits
    129
    Thanked
    0

    Default

    Very Nice...

  5. #5
    Join Date
    16 Aug 2009
    Location
    Makkah , Saudia
    Gender
    Male
    Posts
    12,863
    Threads
    269
    Credits
    53,108
    Thanked
    720

    Default

    Where is the Calculator?

  6. #6
    Join Date
    20 May 2012
    Gender
    Male
    Posts
    6,593
    Threads
    102
    Credits
    22,778
    Thanked
    950

    Default

    جب آپ اس کوڈ کو ۔۔۔۔۔سی ۔۔۔۔یا۔۔۔۔۔سی++ کے سوفٹ وئیر کے کوڈ پیج پر
    پیسٹ
    کریں گےتو
    Calculator
    آپ کے سامنے ہوگا
    یہ
    کہنے کو حکم میرے آقا

  7. #7
    Join Date
    20 May 2012
    Gender
    Male
    Posts
    6,593
    Threads
    102
    Credits
    22,778
    Thanked
    950

    Default

    وعلیکم السلام
    ------
    بہت شکریہ برادر اس شئیرینگ کا

  8. #8
    Join Date
    15 Sep 2016
    Age
    20
    Gender
    Male
    Posts
    44
    Threads
    0
    Credits
    284
    Thanked
    0

    Default

    Very Good Brother.

Similar Threads

  1. Replies: 1041
    Last Post: 29th July 2017, 12:02 PM
  2. Figure translate kro eng main
    By justali in forum General Discussion
    Replies: 27
    Last Post: 14th August 2012, 01:13 PM
  3. Excel Problem
    By Qutab in forum Ask an Expert
    Replies: 17
    Last Post: 18th July 2012, 09:01 PM
  4. Solved Excel main figures(hindsoun) ko words main Badalna....
    By danireh in forum Solved Problems (IT)
    Replies: 4
    Last Post: 17th January 2012, 03:17 PM
  5. Urgent Help Plz
    By jaadoogar in forum Solved Problems (IT)
    Replies: 16
    Last Post: 1st August 2010, 01:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •