TechUncategorized

How to Create Simple Calculator in C++ Program

How to Create Simple Calculator in C++ Program (TurboC++): Hello, Everyone today i am going to share with You guys that how to Create Simple Calculator in C++ Program (TurboC++). This Program will takes an Arithmetic Operator Such as (+,-,/,*).1

How to Create Simple Calculator in C++ Program

1

2

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b;
char op;
cout<<endl<<“Enter the first value=”;cin>>a;
cout<<endl<<“Enter the Second value=”;cin>>b;
cout<<endl<<“Enter the Operator (+,-,/,*)=”;cin>>op;
if (op==’-‘)
cout<<endl<<“Subtraction Answer=”<<a-b;
else
if (op==’+’)
cout<<endl<<“Addition Answer=”<<a+b;
else
if (op==’*’)
cout<<endl<<“Multiplication Answer=”<<a*b;
else
if (op==’/’)
cout<<endl<<“Division Answer=”<<a/b;
else
cout<<endl<<“You entered Invalid operator”;
getch();
}

Addition Answer

Addition

Subtraction Answer

Subtraction

Multiplication Answer

Multiplication

Division Answer

Division

Read Also: How to install Turbo C++: Compile and Run a C++ Program

Related Articles

Leave a Reply

Back to top button