Searching...
Saturday, 23 July 2016

C++ program : How to make Simple Calculator in C++

05:29:00

C++ program : How to make simple Calculator :


#include <iostream>

using namespace std;

int main()
{
    float a, b;
    char c;
    float R;
    cout << "Enter the First Number : \n";
    cin >> a;
    cout << "Enter the Second Number : \n";
    cin >> b;
    cout << "*****What to do?***** \n" << "+ For Addition \n" << "- For Subtraction \n" << "* For Multiplication \n" << "/ For Division \n " ;
    cin >> c;
    if(c=='+' )
        {
        R = a + b;
        cout << R;
        }
        else if(c=='-')
        {
            R = a - b;
            cout << R;
        }
        else if (c=='*')
        {
            R = a * b;
            cout << R;

        }
        else if(c=='/')
        {
            R = a / b ;
            cout << R;

        }
        else
            cout << "Invalid operator ";



    return 0;
}


Output :

C++ program : How to make Simple Calculator in C++
C++ program : How to make Simple Calculator in C++



0 comments:

Post a Comment