#include<stdio.h>
#include<string.h>
#include <math.h>
#define MAX 10
#define A 0.6180339887
int h(int k, int m)
{
return floor(m * (k*A - floor(k*A)));
}
struct telephonebook
{
char name[20];
unsigned int phoneno;
};
int main()
{
struct telephonebook arr_client[MAX];
int recordCount=0;
int arrayIndex=0;
int i;
unsigned int key_phoneno=0;
int flag = 1;
while(flag == 1)
{
printf("Enter Client Phone Number: ");
scanf("%u", &key_phoneno);
//hash calculation using multiplication method
arrayIndex = h(key_phoneno,10);
// using hash value to store a Client Phone record
printf("Enter Client name: ");
scanf("%s", arr_client[arrayIndex].name);
arr_client[arrayIndex].phoneno = key_phoneno;
recordCount++;
printf("Do you want to add more entry:(Yes-> 1/No->0)");
scanf("%d",&flag);
}
printf("\n");
// searching a Client information based on hash value
printf("Enter Phone Number so show the details");
scanf("%u", &key_phoneno);
//hash calculation using multiplication method
arrayIndex = h(key_phoneno,10);
printf("%s\t%u\t",arr_client[arrayIndex].name, arr_client[arrayIndex].phoneno);
return 0;
}