0
This is the question of the URI I thought of this idea more when I’m going to take the rest of float numbers I can’t...
#include <stdio.h>
int main(int dinheiro)
{
int res, res2;
Here I have an array of integers that I think should be float to put the values meores.
int notas[] = {100, 50, 20, 10, 5 ,2};
float moeda, moedas[] = {1.0, 0.50, 0.25, 0.10, 0.05, 0.01};
scanf("%i", &dinheiro);
printf("NOTAS:\n");
for(int i=0;i<=5; i++)
{
res = dinheiro / notas[i];
printf("%d nota(s) de R$ %d.00\n", res, notas[i]);
dinheiro %= notas[i];
}
So far the program runs and does the counting and separation of the notes.
My problem is when it comes to coins...
printf("MOEDAS:\n");
moeda = dinheiro;
Here is the problem, take the rest of float numbers, both here and in the notes part.
for(int j=0;j<=6; j++)
{
res2 = moeda / moedas[j];
printf("%i moedas(s) de R$ %.2f\n", res2, moedas[j]);
moeda = moeda/2;
}
return 0;
}
If anyone has a tip I’d appreciate it...
Here’s an example of how to take the fractional part of the variable.
#include <stdio.h>

int main(){

 int i = 0;
 float j = 3.55;
 i = j; // recebe a parte inteira
 j = j - i; //retira a parte inteira e sobra a parte fracionaria
 printf("%d", i);
 printf("\n%f", j);
 return 0;
}
– Misael
But the exercise is to separate the money into notes and coins ? Or is it to say what a quantity of money looked like, only in denominations of 100, only in denominations of 50, etc.. ?
– Isac
separate the money...
– Wesley Alves Cardoso