Write a c++ program to define a class "city" having data members name population. Accept and display data for 10 cities.
Answers
Answered by
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
0
Answer:
plese what is a output for 10
Similar questions