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
Distinguish between new and malloc and delete and free().
How did c++ start?
How do you generate a random number in c++?
Does c++ have finally?
Which command properly allocates memory a) char *a=new char[20]; b) char a=new char[20]; c) char a=new char(20.0);
What is the use of bit fields in structure declaration?
Explain one method to process an entire string as one unit?
How we can differentiate between a pre and post increment operators during overloading?
What does int * mean in c++?
Explain one-definition rule (odr).
Why is "using namespace std;" considered bad practice?
If a function doesn’t return a value, how do you declare the function?
What is a block in c++?
What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack
What does ios :: app do in c++?