Skip to content

Commit 44bedc3

Browse files
committed
fixed main.cpp
1 parent 3606619 commit 44bedc3

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

main.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
#include <iostream>
22
#include <cmath>
3-
using std::cin;
3+
44
using std::cout;
55
using 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+
}

0 commit comments

Comments
 (0)