Title : = Write a C++ program create a calculator for an arithmetic operator (+, -, *, /). The program should take two operands from user and performs the operation on those two operands depending upon the operator entered by user.

/*Title : = Write a C++ program create a calculator for an arithmetic operator (+, -, *, /). The program should take two operands from user and performs the operation on those two operands depending upon the operator entered by user.*/

#include<iostream>
using namespace std;

int main()
{

int a,c,b;
char ch;
cin>>a;
cin>>ch;
cin>>b;
switch(ch)
{
    case '+':        //Addition
       
        c=a+b;
        cout<<c;
        break;

    case '-':        //Subtraction
       
        c=a-b;
        cout<<c;
        break;

    case '*':        //Multiplication
       
        c=a*b;
        cout<<c;
        break;

    case '/':        //Division
       
        c=a/b;
        cout<<c;
        break;

}
}

Comments

Popular posts from this blog

Priority Scheduling Algorithm Java Program.

Implement UNIX system calls like ps, fork, join, exec family, and wait for process management (use shell script/ Java/ C programming).

Implement a class CppArray which is identical to a one-dimensional C++ array (i.e., the index set is a set of consecutive integers starting at 0) except for the following : 1. It performs range checking. 2.It allows one to be assigned to another array through the use of assignment operator. 3.It supports a function that returns the size of the array.