I'm a First year IT student
and I'm having a
problem with my
vending machine program..

I can't subtract the cost from the input of the user..
can anyone help me with this simple problem?..

``````#include<stdio.h>
#include<conio.h>

struct vendingmachine
{

int x,y;
float cost;
double change;
char nikz;

};
main()
{
int a,b,h;
float x =1.75,y =1.90,change;
{
struct vendingmachine nikz[10];
printf("\n\n\n===============================================================================");
printf("========================   Vending Machine of Errors   ==========================");
printf("================================================================================\n\n\n\n\n");
printf("Drinks name\t		Cost	        Stock in the machine\n\n\n");
printf("1. Cream soda\t 		1.75\$\t		20\n");
printf("2. Grape Soda\t		1.75\$\t		15\n");
printf("3. Cola\t			1.75\$\t		20\n");
printf("4. Lemon-lime\t		1.90\$\t		18\n");
printf("5. Root-beer\t		1.90\$\t		20\n\n");
printf("6. Do you wish to Exit the Program? \n \n \n");
};

scanf("%d",&a);

if(a==1)
printf("You have chosen Cream soda\n");
if(a==2)
{printf("You have chosen Grape soda\n");}
if(a==3)
{printf("You have chosen Cola\n");}
if(a==4)
{printf("You have chosen Lemon-lime\n");}
if(a==5)
{printf("You have chosen Root-beer\n");}
if(a==6)
{printf("Thank you come again\n\n\n");
return 1;}
scanf("%d",&b);
if(a<=3)
{change=b-x;}
else
{change=b-y;}
}``````

Line 18...Why do you have a brace there?

Also line 55

Logic dictates that you must know how much it cost the choice of beverage. After that you need the amount payed, supposedly it would have been entered into variable `b' (you wrote: `scanf("%d",&b);` ) then you compare to see if it was more or less or equal to the amount necessary.