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
Why is c++ still best?
Write a function that swaps the values of two integers, using int* as the argument type?
How do I make turbo c++ full screen?
Are php strings immutable?
What is istream c++?
What is virtual table?
Why is the function main() special?
Write about all the implicit member functions of a class?
How java is different from c and c++?
What is Destructor in C++?
What are the stages in the development cycle?
Is python written in c or c++?
What are files in c++?
Which function cannot be overloaded c++?
Where is atoi defined?