Skip to content

Commit e6f3260

Browse files
update the result and exception error format
I have updated the result format by '' cout << "Result"<<" of "<< x << oper << y <<" is : "<< result << endl; '' in ### To fix the "divide by zero" error and ### To call the Calculator class member functions section, so that the user can better understand what kind of operators and operands he used during input process, so if he will get any error regarding operators and operand can be solved easily. The other thing which I have updated is an exception error message ''Math error: Attempted to divide by Zero'' , so that the user can understand what is zero exception error.
1 parent 3c594af commit e6f3260

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/get-started/tutorial-console-cpp.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ If you build and run the code again at this point, it will still exit after aski
233233
{
234234
cin >> x >> oper >> y;
235235
result = c.Calculate(x, oper, y);
236-
cout << "Result is: " << result << endl;
236+
cout << "Result "<<"of "<< x << oper << y <<" is : "<< result << endl;
237237
}
238238

239239
return 0;
@@ -599,7 +599,7 @@ If you build and run the code again at this point, it will still exit after aski
599599
{
600600
cin >> x >> oper >> y;
601601
result = c.Calculate(x, oper, y);
602-
cout << "Result is: " << result << endl;
602+
cout << "Result"<<" of "<< x << oper << y <<" is : "<< result << endl;
603603
}
604604

605605
return 0;
@@ -711,13 +711,14 @@ Let's handle division by zero more gracefully, so a user can understand the prob
711711
if (oper == '/' && y == 0)
712712
{
713713
cout << "Division by 0 exception" << endl;
714+
cout << "Math error: Attempted to divide by Zero! "<<endl;
714715
continue;
715716
}
716717
else
717718
{
718719
result = c.Calculate(x, oper, y);
719720
}
720-
cout << "Result is: " << result << endl;
721+
cout << "Result"<<" of "<< x << oper << y <<" is : "<< result << endl;
721722
}
722723

723724
return 0;

0 commit comments

Comments
 (0)