Hello I wrote this program it's meant to ask the user to enter the amout of either toy or food but there is a problem can some one please point out where i'am making the mistake.
Code:
#include <stdio.h>
int main()
{
int x=1000;
int toy=10;
int food=30;
int amount;
int totals;
int totalm;
int i;
printf("what do you wish to buy 1 for toy or any other number for food: ");
scanf("%d", &i);
if(i==1)
{
printf("How many individual units of toy do you wish to buy: ");
scanf("%d", &amount);
while (amount != -1) {
totals = toy*amount;
totalm = x-totals;
printf("You have %d money left\n", totalm);
}
}
else
printf("How many individual units of food do you wish to buy: ");
scanf("%d", &amount);
while (amount != -1) {
totals = toy*amount;
totalm = x-totals;
printf("You have %d money left\n", totalm);
}
return 0;
}