#include <stdio.h> // Define a structure tag population with fields men and women struct population { int men; int women; }; // Create a structure within a structure using state and population struct state { char name[50]; // Assuming the state name won't exceed 50 characters struct population pop; }; int main() { struct state s; // Read data printf("Enter state name: "); scanf("%s", s.name); printf("Enter number of men: "); scanf("%d", &s.pop.men); printf("Enter number of women: "); scanf("%d", &s.pop.women); // Display data printf("\nState: %s\n", s.name); printf("Population:\n"); printf("Men: %d\n", s.pop.men); printf("Women: %d\n", s.pop.women); return 0; } #include <stdio....
Posts
Showing posts from May, 2024