[c] doctor visiting management system

Viewer

copydownloadembedprintName: doctor visiting management system
  1. #include <stdio.h>
  2.  
  3. struct Patient{
  4.     char name[25];
  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("\t\t--------------------------------------\n");
  49.     printf("\t\t\tWelcome to main menu!\n");
  50.     printf("\t\t--------------------------------------\n\n");
  51.  
  52.     printf("1. Enter patient's information for visiting doctor\n");
  53.     printf("2. See your patient's visiting time\n");
  54.     printf("3. See patient's information(only admins can check it, PASSWORD PROTECTED!!)\n");
  55.     printf("4. 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.     getchar();
  73.  
  74.     serial = serial + 1;
  75.     return 0;
  76. }
  77.  
  78. void load_info(void){
  79.     int s;
  80.     int initial_hour = 5, visiting_hour, visiting_minute = 0;
  81.  
  82.     printf("\nEnter your serial no : ");
  83.     scanf("%d", &s);
  84.  
  85.     visiting_hour = initial_hour + (s*15)/60;
  86.     visiting_minute = ((s-1)*15)%60;
  87.  
  88.     printf("\nPatient's name : %s", p[s].name);
  89.     printf("\nPatient's age : %s", p[s].age);
  90.     printf("\nPatient's phone no : %s", p[s].phone_no);
  91.     printf("\nyour visiting time : %d.%d pm, %s", visiting_hour, visiting_minute, p[s].day);
  92.  
  93.     return 0;
  94. }
  95.  
  96.  
  97. void load_all_info(void){
  98.     for(int i=0; i<serial; i++){
  99.         printf("\nInformation of patient %d", i+1);
  100.         printf("\nPatient's name : %s", p[i].name);
  101.         printf("\nPatient's age : %s", p[i].age);
  102.         printf("\nPatient's phone no : %s\n\n", p[i].phone_no);
  103.     }
  104.     return 0;
  105. }
  106.  

Editor

You can edit this paste and save as new:


File Description
  • doctor visiting management system
  • Paste Code
  • 06 May-2021
  • 2.45 Kb
You can Share it: