1.Write a program to show list of grocery shop items and also total bill of selected item by user.
#include<stdio.h>
void main()
{
int a,b,c=0,end=1,sum=0;
while(end)
{
printf("Grocery shop\n1.Apple\n2.Banana\n3.Cold Drink\n4.Biscuit\n5.Genrate total Bill\n ");
printf("Please Enter the item number of grocery to add in bucket or To Generate bill press 5=");
scanf("%d",&a);
switch(a)
{
case 1:
printf("Enter the amount of apple in kg=");
scanf("%d",&b);
c=b*120;
sum+=c;
printf("The cost of %d kg apple is %d\n",b,c);
break;
case 2:
printf("Enter the number of dozen banana's=");
scanf("%d",&b);
c=b*50;
sum+=c;
printf("The cost of %d dozen Banana's is %d\n",b,c);
break;
case 3:
printf("Enter the number of Cold Drink bottles=");
scanf("%d",&b);
c=b*30;
sum+=c;
printf("The cost of %d cold drink bottle is %d\n",b,c);
break;
case 4:
printf("Enter the number of biscuit packets=");
scanf("%d",&b);
c=b*10;
sum+=c;
printf("The cost of %d Biscuit packets is %d\n",b,c);
break;
case 5:
end=0;
break;
default:
printf("The Grocerry item number is invalid\n");
}
printf("The Total Bill is %d\n\n\n",sum);
}
}
0 Comments