Sunday 10 September 2017

Calculator

This is my Calculator program. In this program you can enter the entire expression instead of only 2 numbers.Try it and comment below.




#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int a,b;
char c;
system("cls");
cout << "Enter the expression....";
cout << "\nPress '= 'after entering expression....";
cin >> a;
do
{
cin >> c;
switch (c)
{
case '+':cin >> b; a += b; break;
case '-':cin >> b; a -= b; break;
case '*':cin >> b; a *= b; break;
case '/':cin >> b; a /= b; break;
}
} while (c != '=');
cout << a;
_getch();
}




1 comment:

  1. You can ask any questions regarding the above program.
    You can also request me to upload different types of programs

    ReplyDelete