Guest User

Untitled

a guest
Nov 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. static int count=0;
  5. struct tele{
  6. char name[20];
  7. long int num;
  8. };
  9.  
  10. int main()
  11. {
  12. struct tele a[10];//for save the list of numbers.
  13. char temp_name[20];
  14. int checker,i,n= 0;
  15.  
  16. while(n!=5)
  17. {
  18. printf("**Welcome in Telephone Diary.**");
  19. printf("\n\n1.Show the list of diary.\n2.Find a Number.\n3.Add the Number.\n4.Delete the Number.\n5.Exit from the Diary.");
  20.  
  21. printf("Enter your choice:");
  22. scanf("%d",&n);
  23.  
  24. switch(n)
  25. {
  26. case 1:{
  27. if(count==0)
  28. printf("No Number is in Telephone Diary.");
  29.  
  30. else
  31. for(i=0;i<count;i++)
  32. {
  33. printf("%d.%[\n]s",i+1,a[i].name);
  34. printf("\n %ld\n",a[i].num);
  35. }
  36. break;
  37. }
  38.  
  39. case 2:{ if(count==0)
  40. printf("No Number is in Telephone Diary.");
  41.  
  42. else
  43. {
  44. printf("Please Fill Every Details in Capital.\n");
  45. printf("Enter a Name");
  46. scanf("%[\n]s",temp_name);
  47.  
  48. for(i=0;i<count;i++)
  49. {
  50. checker=strcmp(a[i].name,temp_name);
  51. if(checker>0)
  52. {
  53. printf("Your Enter Number is this:\n");
  54. printf("\n %s\n",a[i].name);
  55. printf(" %ld",a[i].num);
  56. break;
  57. }
  58. }
  59. if(i=10)
  60. printf("Your Entered Number is not in List");
  61. }
  62. break;
  63. }
  64.  
  65. case 3:{
  66. if(count==0)
  67. {
  68. printf("\nPlease Fill Every Details in Capital.\n");
  69. printf("Enter a Name:");
  70. scanf("%s",&a[count].name);
  71. printf("Enter a Number:");
  72. scanf("%ld",&a[count].num);
  73. count=count+2;
  74. }
  75. else
  76. {
  77. printf("Please Fill Every Details in Capital.\n");
  78. printf("Enter a Name:");
  79. scanf("%[^\n]s",&a[count-1].name);
  80. printf("Enter a Number:");
  81. scanf("%ld",&a[count-1].num);
  82. count++;
  83. }
  84. break;
  85. }
  86. }
  87. }
  88. return 0;
  89.  
  90. }
Add Comment
Please, Sign In to add comment