Question

1. Briefly explain what is wrong (exactly 1 error) with the following code. auto input = 0.0; cout << Enter input: ; cin >>
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The error in the following code is that in below statement

cout<<"Result 1 = "<<1.0/input<<endl;

It is trying to divide the value by input and user can enter 0 as well which makes it

1.0/0 which is wrong as divide by zero is invalid.

And in case we remove user input and consider the initial value of input which is also zero hence again error.

Output:

Add a comment
Know the answer?
Add Answer to:
1. Briefly explain what is wrong (exactly 1 error) with the following code. auto input =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT