Did i do something wrong in my c++ code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Did i do something wrong in my c++ code?

I tried making a BMI calculator in c++, which is supposed to divide the weight by the height, and then divide the result by the height again, but I'm getting strange output: did I do something wrong? https://code.sololearn.com/cS3yV3vdkl3u/?ref=app

14th Jul 2017, 7:41 AM
X-1
X-1 - avatar
1 Answer
+ 1
change line 17 from: double height = height/100; // this is declaring a new variable out of scope of the rest of the program to: height = height/100; or height /= 100; and move to below line 18: cin >> height; change line 23 from: cin >> weight; to: cin >> height;
14th Jul 2017, 8:04 AM
ChaoticDawg
ChaoticDawg - avatar