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

#include<iostream>
using namespace std;



int main()
{
int bill[]={1000, 500, 100, 50, 20, 10, 5, 1};
int bill_count[]={0,0,0,0,0,0,0,0};

int size=8;
int val=728;


for(int i=0; i<size; i++)
{
if(val > bill[i] )
{

bill_count[i] = (val>=5?val/bill[i]:val);
val = val%bill[i];

}
}

for(int i=0; i<size; i++)
{
cout<< bill_count[i]<<" X " << bill[i]<<endl;
}

system("pause");
exit(0);
}

Is This Answer Correct ?    5 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Evaulate: 22%5 a) 2 b) 4 c) 0

797


Explain function overloading and operator overloading.

752


What is a class definition?

730


What is the iunknown interface?

811


What are static variables?

744






Why c++ is better than c language?

694


Why c++ is so important?

735


Am pass the 10000 records to target in target I will take commit interval 15000 when I was stop the work flow what will happened

1270


Explain pass by value and pass by reference.

708


Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?

905


Does c++ support exception handling?

726


What can I use instead of namespace std?

778


What is size of string in c++?

677


Why would you use pointers in c++?

752


What is object oriented programming (oop)?

772