Write a program to make calculator in C++ Language - Program to make calculator in C++

Program to make calculator in C++ Language

#include <iostream>

using namespace std;

int main()

{

    char cal;

    float x, y;

    cout << endl <<"Enter first number = ";

    cin>> x;

    cout << endl <<"Enter second number = ";

    cin>> y;

    cout << endl <<"Enter operator: ";

    cin>> cal;

    switch (cal)

    {

       case '+':

            cout << endl << x + y << endl;

            break;

       case '-':

            cout << endl << x - y << endl;

            break;

       case '*':

            cout << endl << x * y << endl;

            break;

       case '/':

            cout << endl << x / y << endl ;

            break;

       default:

            cout << endl << "Error!" << endl;

            break;

    }

    return 0;

}


इस कोड को हमने CODEBLOCK पर बना कर run किया है



OUTPUT

For the Addition of two numbers



For the Subtraction of two numbers


For the Multiplication of two numbers



For the Division of two numbers




If the wrong selection of operator


Comments