File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#include < iostream>
22#include < cmath>
3- using std::cin;
3+
44using std::cout;
55using std::endl;
6+ using std::cin;
67
7- int main ()
8+ int main ()
89{
910 cout << " THE FIRST EXAMPLE MATH DISPLAY!\n " ;
1011 cout << " Hi, please enter two whole numbers: " ;
1112
12- int x,y;
13-
13+ int x, y;
1414 cin >> x >> y;
15- cout << " Addition: " << x + y << endl;
15+ cout << " Addition: " << x + y << endl;
1616 cout << " Subtraction: " << x - y << endl;
17- cout << " Multiplication: " << x * y << endl;
18- cout << " Division: " << x / y << endl;
19- cout << " Remainder: " << x % y << endl;
20- cout << " Square Root: " << sqrt (x) << endl;
21- cout << " Square: " << pow (x, y) << endl;
17+ cout << " Multiplication: " << x * y << endl;
18+ if (y == 0 ) {
19+ cout << " Dividing by zero is not a number.\n " ;
20+ }
21+ else {
22+ cout << " Division: " << x / y << endl;
23+ }
24+ cout << " Remainder: " << x % y << endl;
25+ cout << " Square Root: " << sqrt (x) << endl;
26+ cout << " Square: " << pow (x, y) << endl;
2227
23- return 0 ;
24- }
28+ return 0 ;
29+ }
You can’t perform that action at this time.
0 commit comments