#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class country
{ int cntry_id;
char name[20],capital[20];
struct president
{ char lname[20],fname[20];
}pname;
long po;
public:
void getdata()
{ cout<<"enter country id,name,capital,presidents name,population"<<endl;
cin>>cntry_id;
gets(name);
gets(capital);
gets(pname.fname);
gets(pname.lname);
cin>>po;
}
void showdata()
{ cout<<"country id "<<cntry_id<<endl;
cout<<"name "<<name<<"\t capital "<<capital<<endl;
cout<<"presidents name "<<pname.fname<<' '<<pname.lname<<endl;
cout<<"population "<<po<<endl<<endl<<endl;
}
int pcheck(long a)
{ if(po>a)
return (1);
else return(0);
}
void search(char a[])
{ if(strcmp(name,a)==0)
showdata();
}
};
int count(long pop,country c[5])
{ int no=0;
for(int i=0;i<5;i++)
no+= c[i].pcheck(pop);
return no;
}
void main()
{clrscr();
country c[5];
int no;
char a[20];
long p;
for(int i=0;i<5;i++)
c[i].getdata();
cout<<"enter search name"<<endl;
gets(a);
for(i=0;i<5;i++)
c[i].search(a);
cout<<"enter population to check";
cin>>p;
no=count(p,c);
cout<<"no. of countries with population greater then "<<p<<"is"<<no;
getch();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment