Advertisement
prataykumarpaul

sim management project

Jan 20th, 2021 (edited)
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.56 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int Add_info()
  4. {
  5.     char name[30];
  6.     FILE *fptr;
  7.     int id;
  8.  
  9.     float intake, section;
  10.     fptr = fopen("emp.txt", "w+");/*  open for writing */
  11.     if (fptr == NULL)
  12.     {
  13.         printf("File does not exists \n");
  14.         return;
  15.     }
  16.     printf("Enter the id\n");
  17.     scanf("%d", &id);
  18.     fprintf(fptr, "Id= %d\n", id);
  19.     printf("Enter the name \n");
  20.     scanf("%s", name);
  21.     fprintf(fptr, "Name= %s\n", name);
  22.     printf("Enter the Intake\n");
  23.     scanf("%f", &intake);
  24.     fprintf(fptr, "Intake= %.2f\n", intake);
  25.     printf("Enter the Section\n");
  26.     scanf("%f", &section);
  27.     fprintf(fptr, "Section= %.2f\n", section);
  28.     fclose(fptr);
  29.  
  30.     FILE *fp;
  31.    char buff[255];//creating char array to store data of file
  32.    fp = fopen("emp.txt", "r");
  33.    while(fscanf(fp, "%s", buff)!=EOF){
  34.    printf("%s ", buff);
  35.    }
  36.    fclose(fp);
  37. }
  38.  
  39.  
  40. int show_list()
  41. {
  42.     FILE *fp;
  43.    char buff[255];//creating char array to store data of file
  44.    fp = fopen("emp.txt", "r");
  45.    while(fscanf(fp, "%s", buff)!=EOF){
  46.    printf("%s \n", buff);
  47.    }
  48.    fclose(fp);
  49. }
  50.  
  51.  
  52. int sim_info()
  53. {
  54.     printf("Idea Sim OF THE PROJECT: \n");
  55.     printf("1. Sim Info \n");
  56.     printf("2. Sim List \n");
  57.     printf("3. Update Info \n");
  58.     printf("4. Delete Info\n");
  59.  
  60.     int ch;
  61.     printf("Enter your Choice: ");
  62.     scanf("%d", &ch);
  63.     switch(ch)
  64.     {
  65.     case 1:
  66.         Add_info();
  67.         break;
  68.     case 2:
  69.         show_list();
  70.         break;
  71.  
  72.     default:
  73.         printf("Wrong Input\n");
  74.  
  75.     }
  76.  
  77. }
  78.  
  79.  
  80. int User()
  81. {
  82.     printf("Nothing\n");
  83.  
  84. }
  85.  
  86. int Admin()
  87. {
  88.     printf("ADMIN PANEL OF THE PROJECT: \n");
  89.     printf("1. Idea Sim \n");
  90.     printf("2. Login \n");
  91.     printf("3. Sim Information \n");
  92.     printf("4. My Account\n");
  93.     printf("5. Offers \n");
  94.     printf("6. Emergency Contact \n");
  95.     printf("7. Exit \n");
  96.  
  97.     int ch;
  98.     printf("Enter your Choice: ");
  99.     scanf("%d", &ch);
  100.     switch(ch)
  101.     {
  102.     case 1:
  103.         idea_sim();
  104.         break;
  105.     case 2:
  106.         idea_sim();
  107.         break;
  108.  
  109.     default:
  110.         printf("Wrong Input\n");
  111.  
  112.     }
  113. }
  114.  
  115. int main()
  116. {
  117.     printf("PROJECT NAME : SIM MANAGEMENT SYSTEM\n\n\n\n\n\n");
  118.     printf("1. USER LOGIN\n");
  119.     printf("2. ADMIN LOGIN\n");
  120.     int ch;
  121.     printf("Enter Your Choice: ");
  122.     scanf("%d", &ch);
  123.     switch(ch)
  124.     {
  125.     case 1:
  126.         User();
  127.         break;
  128.     case 2:
  129.         Admin();
  130.         break;
  131.  
  132.     default:
  133.         printf("Wrong Input\n");
  134.     }
  135.  
  136.     return 0;
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement