/*Create a telephone directory application and maintain the names and telephone numbers. Get the name of the person whose number to be searched and search through a portion of the array using indexed sequential search.*/
#include<stdio.h> //for standard input/output functions
#include<stdlib.h> //for standard library functions
#include<conio.h> //for console input/output functions
struct tele{ //Defining the the telephone directory structure char name[20]; //To store customer's Name
long tel;
//to store the telephone number
}a[100]; //Initializing the telephone directory structure with an array
void enter(struct tele a[], int n)
//Function to Enter the data in the telephone directory
{
#include<stdlib.h>
#include<conio.h>
struct tele{
printf("\nNow enter the data\n");
for(i=0;i
printf("\nEnter the name:");
fflush(stdin);
printf("\nEnter the telephone number:");
scanf("%ld",&a[i].tel);
}
}
void sort(struct tele a[],int n)
int i,j;
struct tele t;
for(i=0;i
for(j=i+1;j<n;j++)
if(strcmpi(a[i].name,a[j].name)>0)
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
}
void c_index(struct tele index[], int n, struct tele a[],int asize)
int i,j;
for(i=0,j=0;i<n;i++,j++)
index[j]=a[i];
}
index[j]=a[asize-1];
}
{
int i=0,j=0,pos=0;
int high=0,low=0;
if(strcmpi(search,index[isize-1].name)>0||strcmpi(search,index[0].name)<0)
while(i
0 comments:
Post a Comment