# Thread: help me fix one problem with my cash register

1. ## help me fix one problem with my cash register

Thanks for everyones help my program is nearly complete now there is just one problem. It compiles and runs but does not produce the results I want.

Its suppose to tell you how many of each coins is in a specific amount of change for example if its 90 pences it should say 1 of 50, 2 of 20, 0 of 10 and 0 of 5 (pennies are not included).

Instead what is prints out is 256 of 50, 256 of 20, 256 of 10 and 256 of 5 for any amount entered.

Can anyone help me fix this... here is the code:

Code:
```#include<stdio.h>

void Getnum1(int &num1)
{
printf("Please enter a number between 5 and 95 in cents\n");
scanf("%d%*c", &num1);
return;
}

int DoCalc(int num1)
{
int value = 0;

while(num1 >= 50)
{
num1 = num1 - 50;
value = value + 1;
}

while(num1 >= 20)
{
num1 = num1 - 20;
value = value + 1;
}

while(num1 >= 10)
{
num1 = num1 - 10;
value = value + 1;
}

while(num1 >= 5)
{
num1 = num1 - 50;
value = value + 1;
}
return(value);
}

void PrintCal(int &value)
{
printf("(Fifty: %d\n" ,value);
printf("Twenty: %d\n" ,value);
printf("Ten: %d\n" ,value);
printf("Five: %d\n" ,value);
return;
}

int main()
{
int num1;
int value;

Getnum1(num1);
DoCalc(num1);
PrintCal(value);

return(0);
}```
Can anyone help me... thanks in advanced

2. Why did you post it twice?

[Instead what is prints out is 256 of 50, 256 of 20, 256 of 10 and 256 of 5 for any amount entered.
Where do you return the three numbers you want to print out and where do you print them?

3. i was trying to pass it by reference or is that not possible? i am trying to print it in "PrintCal"
Code:
```void PrintCal(int &value)
{
printf("(Fifty: &#37;d\n" ,value);
printf("Twenty: %d\n" ,value);
printf("Ten: %d\n" ,value);
printf("Five: %d\n" ,value);
return;
}```

4. When you are using c++ it is normally better to use std::cout for printing and std::cin for input. I cant really explain why, but I have been told so several times and I am sure some other members here will jump in and give you a reason.

You pass one value to the print function and want it to print out three different values. That is not possible.
And value is never given a value