I cant fix this gets, the next output will be productname:Price: Can someone help me how to fix it?
#include <stdio.h>
int main()
{
int price,quantity,total,cash,change,equal;
char productname[50],c;
do{
printf("\n**** Welcome to my Store ****\n");
printf("\nProduct Name:");
gets(productname);
printf("Price:");
scanf("%d",&price);
printf("Quantity:");
scanf("%d",&quantity);
switch(quantity)
{
case 1 :
{
printf("\nAdd another item? Press 'c' to continue | 'x' to calculate total amount to be paid:");
scanf("%c",&c);
scanf("%c");
if(c!='c' && c!='x')
{
printf("\nInvalid Choice");
break;
}
break;
}
case 2 :
{
printf("\nAdd another item? Press 'c' to continue | 'x' to calculate total amount to be paid:");
scanf("%c",&c);
scanf("%c");
if(c!='c' && c!='x')
{
printf("\nInvalid Choice");
break;
}
break;
}
}
total = price * quantity;
}while(c!='x');
printf("\n________________________________________________________________________");
printf("\nTotal Amount:%d",total);
printf("\nCash:");
scanf("%d",&cash);
change = cash - total;
printf("Change:%d",change);
return 0;
}