0% found this document useful (0 votes)
17 views

C++ Calc

This C++ program is a basic calculator that allows a user to enter two numbers and an operator and displays the result. The program was created by Rajat Thakur and uses a switch statement to evaluate the operator and perform the calculation, displaying the output and clearing the screen for the next calculation.

Uploaded by

Rajat Thakur
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

C++ Calc

This C++ program is a basic calculator that allows a user to enter two numbers and an operator and displays the result. The program was created by Rajat Thakur and uses a switch statement to evaluate the operator and perform the calculation, displaying the output and clearing the screen for the next calculation.

Uploaded by

Rajat Thakur
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<iostream>

using namespace std;

int main(void)
{
cout<<"This Calculater has been made by Rajat Thakur." << endl;

int i,j,x=0;

while(true)
{

cout <<"Enter your operator: ";


char op;
cin >> op;

cout << "Enter the first number: ";


cin >> i;
cout << "Enter the seceond number: ";
cin >> j;

switch(op)
{
case '+':
cout << "Result: " << i+j << endl;
break;
case '-':
cout << "Result: " << i-j << endl;
break;
case '*':
cout << "Result: " << i*j << endl;
break;
case '/':
cout << "Result: " << i/j << endl;
break;
default:
cout << endl << endl << "Please enter a valid operator..." <<
endl;
return 0;
break;
}
system("PAUSE");
system("cls");
}

system("PAUSE");
}

You might also like