Advertisement
StefiIOE

kupuvacka koshnicka

Mar 11th, 2020
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. typedef struct products
  4. {
  5.     char name[100];
  6.     int price;
  7.     int quantity;
  8. }
  9. products ;
  10. int main()
  11. {
  12.     int i,n;
  13.     products p[50];
  14.     scanf("%d", &n);
  15.     for(i=0; i<n; i++)
  16.     {
  17.         scanf("%s",&p[i].name);
  18.         scanf("%d",&p[i].price);
  19.         scanf("%d",&p[i].quantity);
  20.     }
  21.               float total=0;
  22.                   for(i=0; i<n; i++)
  23.               {
  24.                   total+=p[i].quantity*p[i].price;
  25.               }
  26.      int b=1;
  27.     for(i=0; i<n; i++)
  28.     {
  29.        
  30.         printf("%d. %s\t%.2f x %d = %.2f\n",b,p[i].name, (float)p[i].price,p[i].quantity, (float)p[i].price*p[i].quantity);
  31.         b++;
  32.     }
  33.     printf("Total: %.2f\n",total);
  34.               return 0;
  35.               }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement