Design a structure for the Invoice Detail and find total cost of purchase for a product.The structure includes members as Productname ,Quantity,Price.
Input :
Juice
2
15
Output :
Juice
2
15
30
#include <stdio.h>
struct Invoice{
char Productname[20];
int Quantity;
int Price;
};
int main(void)
{
struct Invoice invoice;
int total;
gets(invoice.Productname);
scanf("%d",&invoice.Quantity);
scanf("%d",&invoice.Price);
total =invoice.Quantity*invoice.Price;
printf("%s\n",invoice.Productname);
printf("%d\n",invoice.Quantity);
printf("%d\n",invoice.Price);
printf("%d\n",total);
getchar();
getchar();
return(0);
}
Comments
Leave a comment