C Program to Print Bills [Formatting and Alignment]
This C Program generates bills and formats the output and present it in a tabular view.the items can be changed and to incorporate more items dynamically loops can be added
#include<stdio.h>
main()
{
double milk=7.00;
double shirt=50.00;
double watch=37;
double fridge=1100;
double a,b,c,d;
double h,i,j,k;
printf("Enter the quantity of milk purchased n");
scanf("%lf",&a);
h=a*milk;
printf("Enter the quantity of shirt purchased n");
scanf("%lf",&b);
i=b*shirt;
printf("Enter the quantity of watch purchased n");
scanf("%lf",&c);
j=c*watch;
printf("Enter the quantity of fridge purchased n");
scanf("%lf",&d);
k=d*fridge;
double tbill=h+i+j+k;
printf("BILL SUMMARYn ");
printf("__________________________________________________________________________________________ n");
printf("SL NO ITEM NAME QTY PRICE n");
printf("1. MILK %lf %lf n",a,h);
printf("2. SHIRT %lf %lf n",b,i);
printf("3. WATCH %lf %lf n",c,j);
printf("4. FRIDGE %lf %lf n",d,k);
printf("__________________________________________________________________________________________ n");
printf("TOTAL BILL AMOUNT = %lf n",tbill);
printf("__________________________________________________________________________________________ n");
printf("....HAPPY SHOPPING.... n");
}
OUTPUT:
Enter the quantity of milk purchased
12
Enter the quantity of shirt purchased
32
Enter the quantity of watch purchased
43
Enter the quantity of fridge purchased
9
BILL SUMMARY
__________________________________________________________________________________________
SL NO ITEM NAME QTY PRICE
1. MILK 12.000000 84.000000
2. SHIRT 32.000000 1600.000000
3. WATCH 43.000000 1591.000000
4. FRIDGE 9.000000 9900.000000
__________________________________________________________________________________________
TOTAL BILL AMOUNT = 13175.000000
__________________________________________________________________________________________
….HAPPY SHOPPING….
Recent Comments