pls help..

paper bills.. 1000, 500, 100, 50, 20, 10, 5, 1..

create a program that will count all the paper bills in
the number being input..

example:
enter a number: 3886

there is/are:

3 ->1000
1 ->500
3 ->100
1 ->50
1 ->20
1 ->10
1 ->5
1 ->1

example2:
enter a number: 728

there is/are:

0 ->1000
1 ->500
2 ->100
0 ->50
1 ->20
0 ->10
1 ->5
3 ->1

Answer Posted / etay

int _tmain(int argc, _TCHAR* argv[])
{
int num,i;
int bills[8] = { 1000, 500, 100, 50 ,20 ,10 ,5 ,1 };
int count[8] = {0};
printf("insert the number: \n");
scanf("%d",&num);
for (i=0; i<8;i++)
{
while (num >= bills[i])
{
num-=bills[i];
count[i]++;
}
}

for (i=0;i<8;i++)
{
printf("%d = %d \n",bills[i],count[i]);
}
scanf("%d",&num);

return 0;
}

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why cstdlib is used in c++?

678


What are the two types of polymorphism?

682


What is a v-table?

753


Assume studentNames and studentIDs are two parallel arrays of size N that hold student data. Write a pseudocode algorithm that sorts studentIDs array in ascending ID number order such that the two arrays remain parallel.

1825


Give an example of run-time polymorphism/virtual functions.

646






Can we use this pointer inside static member function?

716


What is the use of function pointer?

657


which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?

826


What is c++ namespace?

812


Why is c++ still used?

696


Write a program using display() function which takes two arguments.

701


Define the process of handling in case of destructor failure?

669


What is the role of static keyword for a class member variable?

725


Explain the static member function.

815


What do you mean by inheritance in c++?

702