Answer to Question #291748 in C for Bhakti

Question #291748

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

1
Expert's answer
2022-01-29T13:02:43-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS