create a phone book program that enables users to enter names and phone numbers of friends and acquaintances. create a structure to hold contact information, and use calloc() to reserve the first memory segment. the user should be able to add or modify phone book entries through a menu. use the realloc() function to add contiguous memory segments to the original memory block when a user adds a new phone book entry.

Respuesta :

The phone book program that enables users to enter names will be:

#include<stdio.h>

#include<stdlib.h>

struct phonebook{

char name[10];

double phoneno;

};

int main()

{

int t,i,total;

typedef struct phonebook phone;

phone *arr;

arr = (phone *)calloc(1,sizeof(phone));

printf("want to add a phone number:(0/1)\t");

scanf("%d",&t);

i = 1;

while(t!=0)

{

printf("enter name:\t");

scanf("%s",arr[i-1].name);

printf("enter phoneno:\t");

scanf("%lf",&arr[i-1].phoneno);

printf("want to add a phone number:(0/1)\t");

scanf("%d",&t);

i++;

arr = (phone *)realloc(arr,i*sizeof(phone));

}

total = i;

for(i=0;i<total-1;i++)

{

printf("name:\t%s",arr[i].name);

printf("\tphoneno:\t%.0lf\n",arr[i].phoneno);

}

What is a computer program?

A computer program is a set of instructions written in a programming language that a computer can execute. Software includes computer programs as well as documentation and other intangible components.

Source code refers to a computer program in its human-readable form. The program based on the information is illustrated above.

Learn more about program on:

https://brainly.com/question/26642771

#SPJ1