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
What is abstraction in c++ with example?
how to explain our contribution in the project?
What can I safely assume about the initial values of variables which are not explicitly initialized?
Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.
What are static and dynamic type checking?
Why c++ does not have finally?
What is a stack? How it can be implemented?
What are mutator methods in c++?
What are the various storage classes in C++?
What is virtual destructor? What is its use?
How to demonstrate the use of a variable?
What is an inline function in c++?
Difference between delete and free.
Can you please explain the difference between static and dynamic binding of functions?
List the special characteristics of constructor.