Greetings,
Firstly, there are a few syntax problems with your provided source.
int pop[20]
nor
int growth[20]
Has a semicolon, which could cause the compiler to result in errors.
Secondly:
for (i=o;i<=19;i++)
may cause a problem as o and 0 are two different things.
Thirdly, calling country[i] can cause your program to fail, as it is an array of characters. For example:
char word[6] = "Hello";
Would be interpereted as word[0] is 'H', word[1] is 'e', word[2] is 'l', and so forth. So we will never really get our full country name per loop around. We can fix this though by changing it to a two dimensional array.
Q. How do those work?
A. Like any two dimensional realm; rows and colums.
For a quick example of how this would work, would be presented as the following:
For instance, take:
int myValue[2][3];
It would appear to be as:
Rows/Columns Column 0 Column 1 Column 2 Column 3
Row 0 myValue[0][0] myValue[0][1] myValue[0][2] myValue[0][3]
Row 1 myValue[1][0] myValue[1][1] myValue[1][2] myValue[1][3]
In the 2-D realm. So if we had:
char letters[2][3] = { {‘A’}, {‘D’, ‘E’} };
It would look like:
Rows/Columns Column 0 Column 1 Column 2
Row 0 A ‘\0’ ‘\0’
Row 1 D E ‘\0’
To simply fix the code, we could change country to:
char country[20][15];
Which contains 20 rows, with 15 letters maximum each.
Fourthly, using "cin >>" to input into the stream is very dangerous, especially when dealing with a limited space character array. You could overflow the arrays boundaries as "cin >>" does not support buffer overflow protection. In a more safer environment, we can use getline() as a substitute:
cin.getline(country[i], 15);
If you have further questions, please feel free to ask.
-Stack Overflow