Hi good day.. i need your help with my exercises..
i need to know how to compute the cents.. in any given amount.. in denominations.. for C programming
Thanks..

Given amount : 1886.25

if (amount>=1000)

x = amount / 1000;
amount % 1000;
printf("%d",&x);

## All 8 Replies

For cents multiply by 100 and take modulo 100

thanks..
but how should i make it..

amount * 100;
100%100

is that it?

Yes it is!

still not showing the cents.. :(

its shows only 1000 , 500, 200 , 100 , 50 , 20 , 10 , 5, 1...
but cents not showing

100%100 will not give you the correct answer I presume.

commented: I checked this with and it gave me zero. +12

Try

``````float amount = 1886.25;
int cents =(int)(amount*100) % 100;``````

I'm still a little confused.
What is an exact example of the output you expect?

input = 1886.25

What do you want the program to show?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.