Calculator Assignment by Afaq 23204
Calculator Assignment by Afaq 23204
#include <cmath>
return x+y;
return x-y;
return x*y;
return x/y;
return x%y;
int main()
cout << " " << "('+' for sum)" << endl;
cout << " " << "('-' for subtraction)" << endl;
cout << " " << "('*' for multiplication)" << endl;
cout << " " << "('/' for division)" << endl;
cout << " " << "('%' for modolus)" << endl;
cout << " " << "('2' for square)" << endl;
cout << " " << "('3' for cube)" << endl;
cout << " " << "('p or P' for exponentiation)" << endl;
cout << " " << "('s or S' for square root)" << endl;
cout << " " << "('c or C' for cube root root)" << endl;
double x;
char ch;
do {
cin >> x;
cout << "Enter an operator or specified charactor to perform different operations :" << endl;
double y;
cin >> y;
if (ch == '+')
else
}
else
double y;
cin >> y;
cout << x << " power of " << y << " = " << pow(x,y);
else
cout <<endl<< "Do you want to calculate further, type 'y' for yes or 'n' for no :" << endl;
return 0;
OUTPUT
//***
('+' for sum)
('-' for subtraction)
('*' for multiplication)
('/' for division)
('%' for modolus)
('2' for square)
('3' for cube)
('p or P' for exponentiation)
('s or S' for square root)
('c or C' for cube root root)
***///
Enter a number :
9
Enter an operator or specified charactor to perform different
operations :
+
Enter another number :
98
9 + 98 = 107
Do you want to calculate further, type 'y' for yes or 'n' for
no :
y
__________________________
Enter a number :
9
Enter an operator or specified charactor to perform different
operations :
3
cube is 729
Do you want to calculate further, type 'y' for yes or 'n' for
no :
y
__________________________
Enter a number :
6
Enter an operator or specified charactor to perform different
operations :
p
Power of 9
6 power of 9 = 1.00777e+007
Do you want to calculate further, type 'y' for yes or 'n' for
no :
y
__________________________
Enter a number :
27
Enter an operator or specified charactor to perform different
operations :
c
cube root is 3
Do you want to calculate further, type 'y' for yes or 'n' for
no :
n
__________________________
Goob by. Have a nice day.