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