A phonebook typically lists the name, address, and telephone number of everyone living in an area. Write code defining a structure template that could be used to store this data. Assume that a name and address will be no more than 30 characters each, and that a telephone number has exactly seven digits.

Respuesta :

Answer:

#include <stdio.h>

struct Phonebook {

   char name[30];

   char address[30];

   int phone_number;

};

int main()

{

   struct Phonebook pb = {"John Josh", "Newyork", 5551234};

   printf("Name: %s \n", pb.name);

   printf("Address: %s \n", pb.address);

   printf("Phone Number: %d \n", pb.phone_number);

   return 0;

}

Explanation:

- Define a struct called Phonebook that has two character arrays to store the value for name and address, and an integer value to hold the phone number

- In the main, define pb to represent a person and assign default values

- Print the name, address and phone number of the pb (person)