This is only the second time I've used the forums. I've been learning c++ off and on for a little over two months and I am doing an exercise to calculate a person's BMI (body mass index). The compiler shows no errors or warnings but when I run the program, right after I enter the first input, all the output text displays and I get the standard Windows runtime error message "bmi.exe has encountered a problem and needs to close" Here is the code.

//bmi.cpp--calculates body mass index
#include <iostream>
int main()

	using namespace std;

	int feet = 1;
	int inches = 1;
	int lbs = 1;

	const int IncHeight = (feet * 12) + inches;
	const int kgs = lbs / 2.2;
	const int MeterHeight = IncHeight * .0254;

	cout << "enter your height in feet ignoring the inches. ___\b\b\b";
	cin >> feet;
	cout << " Now enter the remaining inches. __\b\b";
	cin >> inches;
	cout << "Now your weight in pounds. ___\b\b\b";
	cin >> lbs;

	cout << "Your BMI (Body Mass Index) is " << kgs / (MeterHeight * MeterHeight) << ". Congratulations, ";
    cout << "you now have a magic number to brag about to people who have no clue what it means." << endl;
	return 0;

I think I might be having trouble understanding variable initialization again, but thanks for the help. Also, if there is an operator for raising to powers, not scientific notation, I would appreciate hearing about it since I can't seem to find it in the index

Thanks a lot. I don't want to mark it as solved yet though because I might have more trouble. I'm really looking forward to a time when I can take a course on it instead of just banging my head on the book and hoping some information falls in.

This article has been dead for over six months. Start a new discussion instead.