[c] nothing

Viewer

  1. #include <stdio.h>
  2.  
  3. struct Patient{
  4.     char name[25], day[10];
  5.     int phone_no, age;
  6. }p[100];
  7.  
  8. int serial = 0;
  9.  
  10. int main()
  11. {
  12.     int menu;
  13.     char pass[10];
  14.     char password[10] = "admin";
  15.     
  16.     my_menu();
  17.     printf("\nEnter menu option : ");
  18.     scanf("%d", &menu);
  19.     
  20.     for(int i=1; i>=1; i++){
  21.        
  22.        if(menu==1){
  23.             enter_info();
  24.         }
  25.         else if(menu==2){
  26.             load_info();
  27.         }
  28.         else if(menu==3){
  29.             printf("Enter password : ");
  30.             getchar();
  31.             gets(pass);
  32.             if(strcmp(pass, password)==0){
  33.                 load_all_info();
  34.             }
  35.             else printf("Incorrect password!");
  36.         }
  37.         else if(menu==4){
  38.             printf("\nThanks for using me!!");
  39.             break;
  40.         }
  41.         else printf("wrong keyword!");
  42.     }
  43.         
  44.     
  45. }
  46.  
  47. void my_menu(void){
  48.     printf("--------------------------------------\n");
  49.     printf("\t\tWelcome to main menu!\n");
  50.     printf("--------------------------------------\n");
  51.     
  52.     printf("\t1. Enter patient's information for visiting doctor\n");
  53.     printf("\t2. See your patient's visiting time\n");
  54.     printf("\t3. See patient's information(only admins can check it, PASSWORD PROTECTED!!)\n");
  55.     printf("\t4. exit\n\n");
  56.     return 0;
  57. }
  58.  
  59. void enter_info(void){
  60.     printf("Enter patient's name : ");
  61.     getchar();
  62.     gets(p[serial].name);
  63.     
  64.     printf("Enter age : ");
  65.     getchar();
  66.     scanf("%d", p[serial].age);
  67.  
  68.     printf("Enter phone no : ");
  69.     getchar();
  70.     scanf("%d", p[serial].phone_no);
  71.     
  72.     printf("Enter visiting day(FRIDAY or SATURDAY) : ");
  73.     getchar();
  74.     scanf("%d", p[serial].day);
  75.     
  76.     getchar();
  77.     
  78.     serial = serial + 1;
  79.     return 0;
  80. }
  81.  
  82. void load_info(void){
  83.     int s;
  84.     int initial_hour = 5, visiting_hour, visiting_minute = 0;
  85.     
  86.     printf("\nEnter your serial no : ");
  87.     scanf("%d", &s);
  88.     
  89.     visiting_hour = initial_hour + (s*15)/60;
  90.     visiting_minute = ((s-1)*15)%60;
  91.     
  92.     printf("\nPatient's name : %s", p[s].name);
  93.     printf("\nPatient's age : %s", p[s].age);
  94.     printf("\nPatient's phone no : %s", p[s].phone_no);
  95.     printf("\nyour visiting time : %d.%d pm, %s", visiting_hour, visiting_minute, p[s].day);
  96.     
  97.     return 0;
  98. }
  99.  
  100.  
  101. void load_all_info(void){
  102.     for(i=0; i<serial; i++){
  103.         printf("\nInformation of patient %d", i+1);
  104.         printf("\nPatient's name : %s", p[i].name);
  105.         printf("\nPatient's age : %s", p[i].age);
  106.         printf("\nPatient's phone no : %s\n\n", p[i].phone_no);
  107.     }
  108.     return 0;
  109. }

Editor

You can edit this paste and save as new:


File Description
  • nothing
  • Paste Code
  • 06 May-2021
  • 2.61 Kb
You can Share it: