shutout5591 wrote:
yea, looks good. The only thing I can think of is your naming scheme, Everybody has their own, but I personally don't use abbreviations, i think it looks more professional.
But if it works for you, good job!
It isn't a matter of professionalism. It is a matter of readability. With auto-complete and intelli-sense type functionality in modern IDEs, having variable and function names that are 20 characters isn't a big deal.. you type the first 4 and hit a couple key short cuts and boom it is filled in for you. Much easier to read.
Gadget wrote:
These are relatively simple programs...
Putting the namespace statement inside the main block is a bit odd.
* at least it _used_ to be odd, hopefully one of the younger bit-twiddlers will let me know if something changed!
I'd say it is odd... lol
Code:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
cout << "Please enter your height:______\b\b\b\b\b\b";
int heightInInches;
cin >> heightInInches;
cout << "Please enter your weight in pounds:______\b\b\b\b\b\b";
int weightInPounds;
cin >> weightInPounds;
// these two statements are for converting the height
double heightInMeters = heightInInches * 0.0254;
// and weight to metric units
double weightInKilograms = weightInPounds / 2.2;
double heightInMetersSquared = pow(heightInMeters, 2);
long double bodyMassIndex = weightInKilograms / heightInMetersSquared;
cout << "Your BMI is: " << bodyMassIndex << endl;
return 0;
}
Other than being piddly little example programs, things are looking good! Getting your style down early is important. I wish I had that focus because I wrestle with bad style sometimes even today.