Accept n Country (ccode, cname, population) information and perform the following
a. Display all country details
b. Search country by cname
c. Search country by ccode
d. Display all countries having population greater than 2500000
e. Display country details having maximum population
#include <stdio.h>
struct country {
char cname[50];
int population;
char ccode;
} s[5];
int main() {
int i;
printf("Enter information of countries:\n");
// storing information
for (i = 0; i < 5; ++i) {
printf("Enter country name: ");
scanf("%s", s[i].cname);printf("Enter country name: ");
printf("Enter country code: ");
scanf("%s", s[i].code);printf("Enter country code: ");
printf("Enter country population: ");
scanf("%s", s[i].cname);printf("Enter country population: ");
}
printf("Displaying Information:\n\n");
// displaying information
for (i = 0; i < 5; ++i) {
printf("Country code: ");
puts(s[i].ccode);
printf("Country name: ");
puts(s[i].cName);
printf("Population: ");
puts(s[i].population);
}
return 0;
}
Comments
Leave a comment