How many countries area and populations will i need? ...and what type of loop can i use?

Write a program that repeatedly asks the user to enter the name, area, and population of
various countries.

The user enters countries until they type “quit”. This means that you will need a loop.

The program then displays the country with the largest area, the country with the biggest
population, and the country with the highest density.

--- How many countries,ares and populations will i need in this program... and what type of loop can I use? if so... can you please provide a example to better help me.
You'll probably want a while loop and a dynamically-sized array (or some other data structure such as a list or vector) since you don't know how much data the user will be entering. If you are clever, I think you could compute that largest of the given values as the user enters them, but the naïve method would be to read everything in, then iterate over it and calculate the required data.
How many countries,ares and populations will i need in this program

As many as the user types in. There's nothing in the description you've provided that limits the number.

what type of loop can I use?

Given that you're not looping a pre-defined number of times, you'll probably be best using either a while loop or a do-while loop. You can achieve the same thing with both of them, so use whichever you're most comfortable with.

can you please provide a example to better help me

We're not going to write your code for you. I'm sure your textbook will provide examples of while loops and do-while loops, and if not, you can look at the tutorials on this site.
> How many countries,ares and populations will i need in this program...

names of countries: four
areas: two
populations: two
densities: two

Pseudo 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
33
34
35
36
std::string name_of_country_with_largest_population ;
std::string name_of_country_with_largest_area ;
std::string name_of_country_with_highest_density ;

long long largest_population = 0 ;
double largest_area = 0 ;
double highest_density = 0 ;

std::string name_of_a_country ;
long long its_population ;
double its_area ;
double its_density ;

loop: 
    read in name_of_a_country, its_population , its_area 
    
    if name_of_a_country == 'quit' break out of the loop 
    
    if its_population > largest_population
          TODO: what should de done?
          
    if its_area > largest_area
          TODO: what should de done?
          
    compute: its_density <- its_population / its_area     
     
    if its_density > highest_density
          TODO: what should de done?
          
    repeat the loop. 
    
display name_of_country_with_largest_population
display name_of_country_with_largest_area
display name_of_country_with_highest_density  

end of program 
Topic archived. No new replies allowed.