Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- typedef struct products
- {
- char name[100];
- int price;
- int quantity;
- }
- products ;
- int main()
- {
- int i,n;
- products p[50];
- scanf("%d", &n);
- for(i=0; i<n; i++)
- {
- scanf("%s",&p[i].name);
- scanf("%d",&p[i].price);
- scanf("%d",&p[i].quantity);
- }
- float total=0;
- for(i=0; i<n; i++)
- {
- total+=p[i].quantity*p[i].price;
- }
- int b=1;
- for(i=0; i<n; i++)
- {
- 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);
- b++;
- }
- printf("Total: %.2f\n",total);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement