Hello all. I'm currently studying computer science, and I need some insight concerning data structures.
i'm asked to create the necessary data structure to hold the population and saving factor of all cities.
CITY: Population: Saving factor:
Nicosia 200 0.4
Limassol 120 0.6
Larnaka 65 0.7
Paphos 30 0.75
Paralimni 15 0.8
And this is my code:
#include <iostream.h>
#include <sstream>
using namespace std;
struct Cyprus {
string city;
int population;
float factor;
} nicosia, limassol, larnaka, paphos, paralimni;
int main ()
{
nicosia.population = 200 ;
nicosia.factor = 0.4 ;
limassol.population = 120 ;
limassol.factor = 0.6 ;
larnaka.population = 65 ;
larnaka.factor = 0.7 ;
paphos.population = 30 ;
paphos.factor = 0.75;
paralimni.population = 15 ;
paralimni.factor = 0.8 ;
}
Is this correct or wrong? why?