Calculator Oop

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

#include<iostream> //including

header files
using namespace std; //standard library
int main()
//initializing main function
{
char c; //variable
declearation
float n1,n2;
cout<<"Enter the operation to be perform\n +\t-\t*\t/\
t";//operation to be performed
cin>>c;
cout<<"Enter first number:\t";
//printing first number
cin>>n1; //scaning
first number
cout<<"Enter second number:\t";
//printing second number
cin>>n2; //scaning
second number

switch (c) //using


switch case
{
case'+':cout<<n1+n2<<"\n";
break;
case'-':cout<<n1-n2<<"\n";
break;
case'*':cout<<n1*n2<<"\n";
break;
case'/':cout<<n1/n2<<"\n";
break;

default: cout<<"Enter your valid choice";


}
return 0;
}

You might also like