Output for Two Arrays Not Displaying Correctly

My program is working but the output isn't displaying as it should.

Here's the INPUT:
62 61 59 64 60 54 57 53 60 55

And this is how the OUTPUT should display:
Current heights: 62 61 59 64 60 54 57 53 60 55
Expected heights: 65.1 64.05 61.95 67.2 63 56.7 59.85 55.65 63 57.75

Any help fixing this issue would be appreciated. Here's my code:

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

#include <iostream>

using namespace std;

int main()
{
    double height[10]; 	
    double expHeight[10];  
    
    for (int x = 0; x < 10; x = x + 1)
	{
		height[x] = 0.0;
	}
	    cout << "You are asked to enter heights (in inches) of 10 students. " << endl << endl;
	    
    for (int x = 0; x < 10; x = x + 1)
	{
        cout << "Enter the height of a student: ";
		cin >> height[x];
		expHeight[x] = height[x] * 1.05;
	}
        
    for (int x = 0; x < 10; x = x + 1)
	{
        cout << "Current heights: " << height[x] << endl;
        cout << "Expected heights: " << expHeight[x] << endl;
        } 
  
	system("pause"); 
	return 0;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cout << "Current heights: ";

for ( int x = 0; x < 10; x = x + 1 )
{
        cout << height[x] << ' ';
} 
cout << endl;  

cout << "Expected heights: "

for ( int x = 0; x < 10; x = x + 1 )
{
        cout << expHeight[x]  << ' ';
} 
cout << endl;  
Thanks, Vlad! It works perfectly now...
Topic archived. No new replies allowed.