Look up the syntax of printf(). That's not how you print a variable; the % should be followed with the type specifier, then the variables should be listed as separate arguments after the string.
I change it but it still wont print. Whats the command for displaying the value of a?
I guess is not % after all I tried & and it dosent work either.
Sry I'm complete newbie in programing.
int Result(int cash)
{
int a;
int b;
int c;
int d;
a = 0;
b = 0;
c = 0;
d = 0;
do{
a = a + 1;
} while(cash >= 50);
cash = cash - 50;
printf("\n50 cents\n");
printf("%a");
do{
b = b + 1;
} while(cash >= 20);
cash = cash - 20;
printf("\n20 cents\n");
printf("%b");
do{
c = c + 1;
} while(cash >= 10);
cash = cash - 10;
printf("\n10 cent change\n");
printf("%c");
do{
d = d + 1;
} while(cash >= 5);
cash = cash - 5;
printf("\n5 cent change,%d\n");
printf("%d");
With that, you should be able to figure out the proper syntax. If you have problems with it, post again, but I hope the example will show you how it works.
Ok i fix it but the problem is the program didnt loop and it only do the calculation once when I want it every time cash cash is bigger than > coin = add value of a.
int Result(int cash)
{
int a;
int b;
int c;
int d;
a = 0;
b = 0;
c = 0;
d = 0;
do{
a = a + 1;
} while(cash >= 50);
cash = cash - 50;
printf("\n50 cents\n");
printf("%d", a);
do{
b = b + 1;
} while(cash >= 20);
cash = cash - 20;
printf("\n20 cents\n");
printf("%d", b);
do{
c = c + 1;
} while(cash >= 10);
cash = cash - 10;
printf("\n10 cent change\n");
printf("%d", c);
do{
d = d + 1;
} while(cash >= 5);
cash = cash - 5;
printf("\n5 cent change,\n");
printf("%d", d);