File tree Expand file tree Collapse file tree 1 file changed +46
-8
lines changed
Expand file tree Collapse file tree 1 file changed +46
-8
lines changed Original file line number Diff line number Diff line change 11/*
2- Write a program that given two numbers as input make the main operations.
2+ Write a program that given two numbers as input make the main operations.
33
4- Output:
5- Insert first number: 4
6- Insert second number: 2
4+ Output:
5+ Insert first number: 4
6+ Insert second number: 2
77
8- SUM: 6
9- Difference: 2
10- Multiplication: 8
11- Division: 2
8+ SUM: 6
9+ Difference: 2
10+ Multiplication: 8
11+ Division: 2
1212*/
13+ #include < iostream>
14+
15+ using namespace std ;
16+
17+ int main (){
18+ int num1;
19+ int num2;
20+
21+ cout<< " Insert first number: " ;
22+ cin >> num1;
23+
24+ if (cin.fail ()){
25+ cerr<<" Error: The given value is not a number" <<endl;
26+ exit (1 );
27+ }
28+
29+ cout<< " Insert second number: " ;
30+ cin>> num2;
31+
32+ if (cin.fail ()){
33+ cerr<< " Error: The given value is not a number" <<endl;
34+ exit (1 );
35+ }
36+
37+
38+ cout<< endl<<
39+ " SUM: " << num1 + num2<< endl<<
40+ " Difference: " << num1 - num2<< endl<<
41+ " Multiplication: " << num1 * num2 << endl;
42+
43+ if (num2 == 0 ){
44+ cout<<" Division: Unable to divide by 0" << endl;
45+ return 0 ;
46+ }
47+
48+ cout<< " Division: " << num1 / num2 <<endl;
49+ return 0 ;
50+ }
You can’t perform that action at this time.
0 commit comments