FAQ: Errors - Run-time Errors

This community-built FAQ covers the “Run-time Errors” exercise from the lesson “Errors”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn C++

FAQs on the exercise Run-time Errors

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Learn more about how to use this guide.

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I got 0 when i ran the program. This feels wrong.

1 Like

Interesting to know that when the width and length are defined as integers, the ratio (regardless of how it’s defined) will also be an integer.

To give a more accurate ratio, all of them should be defined as float / double.

  1. The clues were already given in the type of possible errors.
  2. If you note the actual program instruction you would notice that the programmer forgot the actual dimensions and input the wrong dimension in the program.
  3. By instinct many of us tried to change the type of input from int to float/double. It would be necessary only if there are fractions that would make the calculations relevant. For this particular program float/double is not necessary.

Your point #2 about wrong dimensions is correct. But as noted by @ array7807995251 and @ arcwhiz72232, if we don’t change the type from int to double, then the result isn’t quite correct. 20 divided by 30 clearly isn’t equal to 0. If we leave both inputs as type int, then integer division will be carried out and the fraction part will be thrown away which is not quite the desired behavior.