Problem with exercise

Idk what I'm doing and it keeps saying "'INCHES_PER_FOOT' is used uninitialized in this function 'CENTIMETERS_PER_INCH' is used uninitialized in this function. Trying to get it to stop saying that and then make INCHES_PER_FOOT and CENTIMETERS_PER_INCH display some values. All help is highly appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  // my second program in C++
#include <iostream>

using namespace std;

int main ()
{
    //declare variables
	int feet;
	int inches;
	int totalInches;
	int INCHES_PER_FOOT;
	int CENTIMETERS_PER_INCH;
	double centimeter;
	
cout << "Enter two integers, one for feet and one for inches and one for inches: ";
cin >> feet;
cin >> inches;

cout << "The numbers you entered are ";
cout << feet; 

cout << "for feet and "; 
cout << inches; 

cout << "for inches ";
cout << endl;

totalInches = INCHES_PER_FOOT * feet + inches;

cout << "The total number of inches = ";
cout << totalInches;
cout << endl;

centimeter = CENTIMETERS_PER_INCH * totalInches;

cout << "The number of centimeters = ";
cout << centimeter;
cout << endl;
system ("pause");

return 0;
}
well, they are!
it isn't an error to fail to initialize but some settings warn you about it.
but it is an error (at the very least, a bug) to use the value without it having a valid value, which you do on line 29.
the names indicate they might be conversion factors.
so, most likely, you want
const int inches_per_foor = 12; for example.

I understand I have to assign a value to it, how to put the "const int inches_per_foot=12" just typing it in at line 29 doesn't do anything. Also how do I make a space in-between line 17 and line 18 for example.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Idk what I'm doing and it keeps saying "'INCHES_PER_FOOT' is used 
// uninitialized in this function 'CENTIMETERS_PER_INCH' is used uninitialized 
// in this function. Trying to get it to stop saying that and then make 
// INCHES_PER_FOOT and CENTIMETERS_PER_INCH display some values.

// my second program in C++
#include <iostream>

using namespace std;

int main ()
{
    cout << "Enter two integers, one for feet and one for inches and one for inches: ";
    int feet = 0;
    int inches = 0;
    cin >> feet;
    cin >> inches;

    cout << "The numbers you entered are ";
    cout << feet; 

    cout << " for feet and "; // a space added at the beginning
    cout << inches; 

    cout << " for inches "; // a space added at the beginning
    cout << endl;

    int INCHES_PER_FOOT = 12;
    int totalInches = INCHES_PER_FOOT * feet + inches;

    cout << "The total number of inches = ";
    cout << totalInches;
    cout << endl;

    double CENTIMETERS_PER_INCH = 2.54;
    double centimeter = CENTIMETERS_PER_INCH * totalInches;

    cout << "The number of centimeters = ";
    cout << centimeter;
    cout << endl;
    system ("pause"); // <-- not portable.
                      // Compare: http://www.cplusplus.com/forum/beginner/1988/

    return 0;
}

Thanks for all the responses, ty for helping me solve this issue Enoizat
Topic archived. No new replies allowed.