void coin(int num)
{
int val[6] = {0};
if(num / 40 > 0)
{
val[0] = num / 40;
num = num %40;
}
if(num / 39 > 0)
{
val[1] = num / 39;
num = num %39;
}
if(num / 24 > 0)
{
val[2] = num / 24;
num = num %24;
}
if(num / 23 > 0)
{
val[3] = num / 23;
num = num %23;
}
if(num / 17 > 0)
{
val[4] = num / 17;
num = num %17;
}
if(num / 16 > 0)
{
val[5] = num / 16;
num = num %16;
}
printf( " 40 :: %d \n 39 :: %d \n 24 :: %d \n 23 :: %d \n 17 :: %d \n 16 :: %d \n Remaining Value :: %d" , val[0],val[1],val[2],val[3],val[4],val[5],num);
}
void main()
{
coin(100);
coin(0);
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.