#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Define a structure to represent a person
struct Person {
char name[50];
int age;
};
// Function to read information about Scranton inhabitants
void readScrantonInhabitants(struct Person *people, int numPeople);
// Function to print information about Scranton inhabitants
void printScrantonInhabitants(const struct Person *people, int numPeople);
int main() {
// Declare an array to store information about Scranton inhabitants
struct Person scrantonPeople[5];
// Call the function to read information about Scranton inhabitants
readScrantonInhabitants(scrantonPeople, 5);
// Call the function to print information about Scranton inhabitants
printScrantonInhabitants(scrantonPeople, 5);
return 0;
}
void readScrantonInhabitants(struct Person *people, int numPeople) {
// Use a loop to read information about each person
for (int i = 0; i < numPeople; i++) {
printf("Enter name for person %d: ", i + 1);
scanf("%s", people[i].name);
printf("Enter age for person %d: ", i + 1);
scanf("%d", &people[i].age);
}
}
void printScrantonInhabitants(const struct Person *people, int numPeople) {
// Print a header for the output
printf("\nScranton Inhabitants:\n");
// Use a loop to print information about each person
for (int i = 0; i < numPeople; i++) {
printf("Person %d:\n", i + 1);
printf("Name: %s\n", people[i].name);
printf("Age: %d\n", people[i].age);
printf("\n");
}
}