Hey everyone! I'm taking a programming class in college, and it's been going really well so far. We do 2 labs a week, and each lab has us fix/write 3-5 programs. I'm on the 13th lab at the moment, and I can't seem to figure out why it's outputting 0. This lab is introducing us to using int when declaring variables.
Alright. Do you know why it would output 0 when int was being used to declare some variables? For example, I would put 66 for the height and 155 for the weight, and it'd give me 0.
Because of the nature of integer division : 155/ (66 * 66) is less than 1 so it returns 0.
Also be careful of integer overflow that can sometimes be a problem, or at least something that should be checked for a robust application. Check out the limits header if interested.