# Thread: creating a coin counting in c

1. ## creating a coin counting in c

I am writing a program in c . The idea is to give a money value ;i.e. 2,75 and the program must give an output which will be the minimum number of coins (quarters,dimes,nickels,pennies) needed to reach the above value.
My code is the following:
Code:
```#include <stdio.h>
#include <math.h>```
Code:
```int main(void)
{
printf("Give an amount: ");
int n;
int d;
}
do
{
printf("non-negative numerator:");
n = GetInt();
}
while (n < 1);
do
{
printf("positive denominator: ");
d = GetInt();
}
{
while (d < 1);
float a = (n / d);
printf("%.2f \n", a);
}
int (cent , nickle , dime ,penny ,sum);
do
{
cent = round(n * 100);
while (cent >= quarter);

cent = (cent - quarter);
count++;

while (cent >= dime);

cent = (cent - dime);
count++;

while (cent >= nickle);

cent = (cent - nickle);
count++;

while (cent - penny);

cent = (cent - penny);
count++;
printf("%d",count);
// ​??????????????????
return 0;
}```
Can anyone help me to complete the code and make it run properly, because I'm confused?

2. Code:
`int (cent , nickle , dime ,penny ,sum);`
This makes no sense.

Also you use getInt() function, but you haven't implemented it somewhere.

3. What must I do in order getInt function make sense

Originally Posted by std10093
Code:
`int (cent , nickle , dime ,penny ,sum);`
This makes no sense.

Also you use getInt() function, but you haven't implemented it somewhere.

4. Can you tell me how the sum of coins will work?

5. "getInt" function is used at CS50 classes and to use it you must #include <cs50.h>
And of course you must use their CS50 appliance as your compiler for it to recognize this header file.

6. Thank you

I modified the code as:
Code:
```int main(void)
{
printf("Give me an amount: ");

}

void change(int *pennies, int *nickels, int *dimes, int *quarters);
do
{
cent = round(n * 100);
while (cent >= quarter);

cent = (cent - quarter);
count++;

while (cent >= dime);

cent = (cent - dime);
count++;

while (cent >= nickel);

cent = (cent - nickel);
count++;

while (cent - penny);

cent = (cent - penny);
count++;
printf("%d",count);

return 0;
}```
Does it make any sense

7. Originally Posted by vag3621
Does it make any sense
No.

There are so many problems that I recommend rereading your book/tutorial/other learning resource.

Bye, Andreas

8. Hi,

I was working on the same problem, but luckily it is now resolved.
You will find my code on this site in the thread called "Whats wrong with my code".
It is now on the first page of this forum but may be pushed down by the time you read this.
You will also find very similar code here: greedy.c - danieleugenewilliams - Dan&#39;s Projects - Google Project Hosting
Between these two codes you should be able to find pointers to write your own.

Good luck.
Kamil