Advertisement
jbn6972

OBA

Dec 2nd, 2021
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.80 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. struct Department
  4. {
  5.     int dep_id;
  6.     int sale[11];
  7. };
  8. int main()
  9. {
  10.     int itm;
  11.     int sales_figure;
  12.     int choice;
  13.     struct Department store[21];
  14.     printf("Enter the Records");
  15.     for (int i = 1; i <= 20; i++)
  16.     {
  17.         printf("\nBranch :: %d", i);
  18.         while (1)
  19.         {
  20.             for (int j = 0; j <= 10; j++)
  21.             {
  22.                 store[i].sale[j] = 0;
  23.             }
  24.             printf("\nEnter the item number (1-10):: ");
  25.             scanf("%d", &itm);
  26.             printf("\nEnter the amount of sales for item %d :: ", itm);
  27.             scanf("%d", &sales_figure);
  28.             store[i].sale[itm] = sales_figure;
  29.             printf("\nPress 1 to enter details of another item or any other number to go enter details of next branch :: ");
  30.             scanf("%d", &choice);
  31.             if (choice != 1)
  32.             {
  33.                 break;
  34.             }
  35.             // store[]
  36.         }
  37.     }
  38.     printf("\n----------------------------------------------Data---------------------------------------------");
  39.     printf("\nBranch\t\tItem::1\t\tItem::2\t\tItem::3\t\tItem::4\t\tItem::5\t\tItem::6\t\tItem::7\t\tItem::8\t\tItem::9\t\tItem::10\tTotal Sales");
  40.     int grand_total = 0;
  41.     for (int i = 1; i <= 20; i++)
  42.     {
  43.         int total = store[i].sale[1] + store[i].sale[2] + store[i].sale[3] + store[i].sale[4] + store[i].sale[5] + store[i].sale[6] + store[i].sale[7] + store[i].sale[8] + store[i].sale[9] + store[i].sale[10];
  44.         printf("\n%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d", i, store[i].sale[1], store[i].sale[2], store[i].sale[3], store[i].sale[4], store[i].sale[5], store[i].sale[6], store[i].sale[7], store[i].sale[8], store[i].sale[9], store[i].sale[10], total);
  45.         grand_total += total;
  46.     }
  47.     printf("\n------------------------------------------------------------------------------------------------------------------------------------------------------------------  Grand Total :: %d", grand_total);
  48.  
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement