Computer Science, asked by darkangel6, 3 months ago

Write a c++ program to define a class "city" having data members name population. Accept and display data for 10 cities.​

Answers

Answered by GitanjaliBhintade
12

Answer:

Program :

#include<iostream.h>

#include<conio.h>

class city

{

public:

int population;

char name[40];

void accept();

void display();

} ;

void city::accept()

{

cout<<"\n Enter name of city:";

cin>>name;

cout<<"\n Enter the population of city:";

cin>>population;

}

void city::display()

{

cout<<"\n Name of City :"<<name;

cout<<"\n Population :"<<population;

}

void main()

{

int i;

clrscr();

city c[10];

for(i=0;i<=9;i++)

{

c[i].accept();

cout<<"\n";

}

for(i=0;i<=9;i++)

{

c[i].display();

cout<<"\n";

}

getch();

}

Answered by harshjasani261
0

Answer:

plese what is a output for 10

Similar questions