# Thread: I Have A Questio here

1. ## I Have A Questio here

Why I can't print out the change due with my coding?anyone can solve it to me?
Code:
```#include<stdio.h>
#include<math.h>

void main()
{
int discount,set_of_combo;
double total,a_payable,amount,cash;
double g_tax,s_tax,change_due,a_a_payable;

printf("Enter Number Of Combo Set : ");
scanf("%d",&set_of_combo);

printf("Enter Discount Voucher (RM) : ");
scanf("%d",&discount);

//calculation
amount = set_of_combo*7.88;
g_tax = amount * 6 / 100;
s_tax = amount *10 / 100;
total = g_tax + s_tax + amount;
a_payable = total - discount;
a_a_payable = a_payable;
change_due = cash - a_a_payable

printf("Good Day and Welcome To KLFC Sdn.Bhd");

printf("R E C E I P T\n");
printf("+-------------------------+------------------+-------------------+\n");
printf("+       Description       |       Rate       |     Amount(RM)    |\n");
printf("+-------------------------+------------------+-------------------+\n");
printf("+      COMBO SET * %d      |       7.88       |        %.2f      |\n",set_of_combo,amount);
printf("+      Goverment Tax      |        6%%        |        %.2f       |\n",g_tax);
printf("+      Service Tax        |        10%%       |        %.2f       |\n",s_tax);
printf("+-------------------------+------------------+-------------------+\n");
printf("+               S U B   T O T A L            |          %.2f    |\n",total);
printf("+============================================+===================|\n");
printf("+      Discount Vouvher (RM)  %.2lf                               +\n",discount);//discount voucher
printf("+                           --------                             |\n");
printf("+      Amount Payable         %.2lf                              |\n",a_payable);//amount payable
printf("+                           ========                             |\n");
printf("=================================================================+\n");
printf(" CASH ");
scanf("%.2lf",&cash);
printf(" Change Due:\n",change_due);
printf("==================================================================\n");
printf("               THANK YOU and HAVE A NICE DAY\n");

}```

2. Presumably because you don't do

change_due = some_expression_involving_cash_and_amount_due;

3. i changed...the out come like this..

Enter Number Of Combo Set : 4
Enter Discount Voucher (RM) : 2
Good Day and Welcome To KLFC Sdn.BhdR E C E I P T
+-------------------------+------------------+-------------------+
+ Description | Rate | Amount(RM) |
+-------------------------+------------------+-------------------+
+ COMBO SET * 4 | 7.88 | 31.52 |
+ Goverment Tax | 6% | 1.89 |
+ Service Tax | 10% | 3.15 |
+-------------------------+------------------+-------------------+
+ S U B T O T A L | 36.56 |
+============================================+==== ===============|
+ Discount Vouvher (RM) 0.00 +
+ -------- |
+ Amount Payable 34.56 |
+ ======== |
+ Adjusted Amount Payable 34.56 |
================================================== ===============+
CASH 44
Change Due:
================================================== ================
THANK YOU and HAVE A NICE DAY
Press any key to continue

4. Originally Posted by Salem
Presumably because you don't do

change_due = some_expression_involving_cash_and_amount_due;
i changed...the out come like this..

Enter Number Of Combo Set : 4
Enter Discount Voucher (RM) : 2
Good Day and Welcome To KLFC Sdn.BhdR E C E I P T
+-------------------------+------------------+-------------------+
+ Description | Rate | Amount(RM) |
+-------------------------+------------------+-------------------+
+ COMBO SET * 4 | 7.88 | 31.52 |
+ Goverment Tax | 6% | 1.89 |
+ Service Tax | 10% | 3.15 |
+-------------------------+------------------+-------------------+
+ S U B T O T A L | 36.56 |
+============================================+==== ===============|
+ Discount Vouvher (RM) 0.00 +
+ -------- |
+ Amount Payable 34.56 |
+ ======== |
+ Adjusted Amount Payable 34.56 |
================================================== ===============+
CASH 44
Change Due:
================================================== ================
THANK YOU and HAVE A NICE DAY
Press any key to continue

5. So show us what you did to the code.

And don't forget, you need a format conversion in the print statement as well.

6. Originally Posted by Salem
So show us what you did to the code.

And don't forget, you need a format conversion in the print statement as well.
what did you mean?

7. Code:
`printf(" Change Due:\n",change_due);`
Do you expect this to print a number? Why?

8. Originally Posted by tabstop
Code:
`printf(" Change Due:\n",change_due);`
Do you expect this to print a number? Why?
ya..>.<...because above the statement also use this way to print out..anything wrong with it?

9. Originally Posted by tokipatrick
ya..>.<...because above the statement also use this way to print out..anything wrong with it?
You really really need to learn to read a little better. Compare that statement with the "above statement" that works and notice the difference.

10. Originally Posted by tabstop
You really really need to learn to read a little better. Compare that statement with the "above statement" that works and notice the difference.
i am blur with it..>.<..i am sorry,i still new with C++ language...

11. Originally Posted by tokipatrick
i am blur with it..>.<..i am sorry,i still new with C++ language...
That's okay, you're not writing C++. Anyway, do you know how to print a number?

12. Originally Posted by tabstop
That's okay, you're not writing C++. Anyway, do you know how to print a number?
you mean after the calculation?

13. Originally Posted by tokipatrick
you mean after the calculation?
I mean at all. Do you know how to print any kind of number?

14. As in,

why do you think this line prints a value,