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 / anand

nt main()
{
int number,count;
int currency[] = {1000, 500,100,50, 20, 10,5, 1};
cout<<"enter the number";
cin>>number;
for(int i=0; i<8;++i)
{
count = 0;
while(number >= currency[i])
{
number -= currency[i];
++count;
}
cout<<count<<"---"<<currency[i]<<"notes"<<endl;
}

getchar();
cout<<endl;

return 0;
}

Is This Answer Correct ?    4 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is meant by forward referencing and when should it be used?

560


Explain the concept of memory leak?

631


Explain selection sorting?

638


What is == in programming?

616


Is ca high or low level language?

586






Why do we use setw in c++?

646


What is the correct syntax for inheritance a) class aclass : public superclass b) class aclass inherit superclass c) class aclass <-superclass

691


How do you traverse a btree in backward in-order?

626


what is multi-threading in C++?

617


What is the auto keyword good for in c++?

626


What is an html tag?

632


What do you mean by translation unit in c++?

676


In a function declaration what does extern means?

600


Explain the scope of resolution operator.

633


Explain differences between new() and delete()?

622