write a c++ program to define a class"city" having data member name.popualation .accept and display data for 10 cities
Answers
Answered by
0
Answer:
c++
Explanation:
idk
Answered by
0
given - write a c++ program to define a class"city" having data member name.popualation .accept and display data for 10 cities
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();
}
please mark my answer as the brainliest
Similar questions