Hello, I am doing a simple program out of my text book (it's not required by the school but I want to learn it) and whenever I input a inch value on the compiled program, it gives me some long ass scientific number. Here is the code. I am using Visual Studio C++ 6
int main()
{
//declaring data types
int feet;
int inches;
int totalInches;
double centimeters;
// output and input for inches
cout << "Enter two integers, one for feet and "
<< "one for inches: ";
cin >> feet, inches;
cout << endl;
cout << "The numbers you entered are " << feet
<< " for feet and " << inches
<< " for inches." << endl;
// calculating inches
totalInches = INCHES_PER_FOOT * feet + inches;
cout << "The total number of inches = "
<< totalInches << endl;
// calculating centimeters
centimeters = CENTIMETERS_PER_INCH * totalInches;
cout << "The total number of centimteres = "
<< centimeters << endl;
return 0;
}
Here is the output. Do note I enter 1 1 for the inputs:
Enter two integers, one for feet and one for inches: 1 1
The numbers you entered are 1 for feet and -858993460 for inches.
The total number of inches = -858993448
The total number of centimteres = -2.18184e+009
Press any key to continue
I also get this warning when I compile it:
d:\program files\microsoft visual studio\myprojects\test2\test2.cpp(28) : warning C4700: local variable 'inches' used without having been initialized
Thank you!
int main()
{
//declaring data types
int feet;
int inches;
int totalInches;
double centimeters;
// output and input for inches
cout << "Enter two integers, one for feet and "
<< "one for inches: ";
cin >> feet, inches;
cout << endl;
cout << "The numbers you entered are " << feet
<< " for feet and " << inches
<< " for inches." << endl;
// calculating inches
totalInches = INCHES_PER_FOOT * feet + inches;
cout << "The total number of inches = "
<< totalInches << endl;
// calculating centimeters
centimeters = CENTIMETERS_PER_INCH * totalInches;
cout << "The total number of centimteres = "
<< centimeters << endl;
return 0;
}
Here is the output. Do note I enter 1 1 for the inputs:
Enter two integers, one for feet and one for inches: 1 1
The numbers you entered are 1 for feet and -858993460 for inches.
The total number of inches = -858993448
The total number of centimteres = -2.18184e+009
Press any key to continue
I also get this warning when I compile it:
d:\program files\microsoft visual studio\myprojects\test2\test2.cpp(28) : warning C4700: local variable 'inches' used without having been initialized
Thank you!