5 like 0 dislike
14k views

Write a program that input a New Taiwan Dollar amount and then shows how to pay that amount using the small bills of $1000, $500, $100, $50, $10, $5 and $1.

將台幣現鈔換成1000, 500, 100, 50, 10, 1 元零錢

Example input:

763

Example output:

NT$1000 bills:0
NT$500 bills:1
NT$100 bills:2
NT$50 bills:1
NT$10 bills:1
NT$5 bills:0
NT$1 bills:3

Hint: Divide the amount by 1000 to determine the number of $1000 bills needed, and then reduce the amount by the total value of the $1000 bills. Repeat for the other bills sizes. Be sure to use integer values throughout, not floating-point numbers.

[Exercise] Coding (C) - asked in Chapter 4: Expressions by (12.1k points)
ID: 25731 - Available when: Unlimited - Due to: Unlimited

reshown by | 14k views

69 Answers

0 like 0 dislike
Hidden content!
#include ** * * *
int main()
{
***** * * * * *** * samt, ramt, tbill, fhbill, hbill, fifbill, tenbill, fvbill, obill;

** * * **** ***** *** *** * * ** &samt);

** ** ********* * ** * ** * * *
* **** *** ** ***** * **** * ** *
**** * **** * ** **** * *
**** * * *** * * * * * *** *
** * * **** *** *** * * ** *
** * ** * * * ** * ** * ** *
*** * ******** * ** * * ****
* * ** *** * * * *** **** *** *****
**** * * ** * ** *** * **
* ** ** * * **** ** * ** ****
** ********* *** *** * ** * *
***** ** * * * **** * ** * *** *
** * ***** * * * ** *** ** *

* *** * ***** * * ** *** **** bills:%d\n", tbill);
** * ****** * * ****** ** * * * *** bills:%d\n", fhbill);
*************** *** ** * * * * ** ** * * * * ** *** * hbill);
*** * **** * ** * * * **** * bills:%d\n", fifbill);
***** * * * * * * * * *** ** ** * bills:%d\n", tenbill);
* * ** * ** *** * * * * * bills:%d\n", fvbill);
* * * * ** * * * * ******* bills:%d", obill);

* ** * ** ** * * 0;
}
answered by (-168 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main() {
**** * *** ** * ** *
* **** *** *** * * * * ** * bill;
** ***** * ** * *** **
** **** * ** ** * * th =1000;
*** *** * * ** * fvh=500;
* *** * * * * * * * * hn = 100;
** ***** ****** * ft = 50;
* ** ** * ** * * * * tn = 10;
* *** * * * * ***** * fv = 5;
* *** * * *** ** **** on = 1;
****** ****** ***** **
* * *** * ******* * * * * **** * *** *
* ** * ** ** * * *** ** * * * ***** * &bill);
* *** ** **** ****
** * *** * ** * *** * ** = (bill/th);
**** ** * ** * * * *** * ** *** *
***** ** * *** * *** ** * * ***
* * ***** * ** * * ***** * *
* * * * * ** ** * * * * **
* ** * * * * ** ***** * ** *
* *** *** *** *** ** * * * *
*** * ** * * ** *** *
** * * * * **** ***** * * * * ** * bills:%d\n", s1);
**** *** * * * ** ** ** *** *** bills:%d\n", s2);
** * **** ** * **** ** * * ** * ** * * bills:%d\n", s3);
* * * ** * * * ** * * *** * ** bills:%d\n", s4);
* ** * * * *** * *** ** ** * bills:%d\n", s5);
* * ** * *** * ** *** * * ** * bills:%d\n", s6);
* ** ** * *** * ** * ** ** ** bills:%d", s7);


* * *** * *** * * ** 0;
}
answered by (323 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>

int main()
{
* * * * ** ** * money;
** * ** * ** ** * *** ** sum1;
* ****** ** * sum2;
*** ******** *** * *** * ** sum3;
* ** ** ** * * * *** * * ** sum4;
** * * ** **** * * * sum5;
***** *** * * ***** * sum6;
*** ****** *** *** ** sum7;
* * ** * * ** * *** *
****** * * * **** * ****** ** * &money);
* *** ** * ** * **
** ****** * ***** ** *** ***
** * * * * * * * * * ** *** * ** **
* ** ****** * ***** * *
* * * * * * * * *** **
* **** * ***** * ** ** * *
* * ** ***** ** * ** * * * **
* * * *** ** *** * * * * * **
* ***** ** ** ** ****** *
** * ****** * ***** ** * ** * ** * ** bills:%d\n", sum1);
** ** ** * * **** * ** ** * * * * bills:%d\n", sum2);
******** ** *** *** * **** * *** bills:%d\n", sum3);
********** * *** * * * **** * * * bills:%d\n", sum4);
** * ** * * ** * ** ** bills:%d\n", sum5);
* * **** * * **** ***** * **** ** bills:%d\n", sum6);
**** *** * ** *** * * *** *** bills:%d", sum7);
** *** * * ** *
* ** * * * * ** ***
*** ** ** ** *** ****** * 0;
}
answered by (-193 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include **** * *

int main()
{
** * ** ** * * * * ****** ** money;
* * ** * *** * ** ** **** sum1;
***** * * ** ** * * ** sum2;
****** * * ***** * * * sum3;
*** *** * * *** *** sum4;
* * *** * * ** ** * *** * ** * sum5;
*** *** * ** * * *** sum6;
*** ******* * ** ***** * sum7;

** * * * *** * * * * * * ***** &money);
* * ** * * *** *** **
* ** * * ** * * * * * ** *
* * ** * * ********** * ******** ** ** *
** ** * *** * ** * * * ****
* * * * **** * * *** ** ** * *
**** ** * * ** ** **** ** *
* * * * * * * *** *** *** *
********* * * * *** * * ** *
** *** **** *** **
*** * * ** ****** ** ** * * * * ** * * ** bills:%d\n", sum1);
* * ******* * * ** ** * * ***** * bills:%d\n", sum2);
** ** * ** ** * * **** *** * * bills:%d\n", sum3);
******** * ** *** * * ** * * ** bills:%d\n", sum4);
* ** ** **** **** *** * * * * bills:%d\n", sum5);
***** ***** * *** ******* * * * *** * bills:%d\n", sum6);
* ** * * **** * * * *** bills:%d\n", sum7);
 
 
** ** * * **** * ** * * * 0;
}
answered by (-193 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include *** * **** *

int main ()

{
*** **** ** * * ** ** ** ** *
***** * *** ******* * **** &ones);
* **** * * * ** = ones/1000;
* ** ** * *** ** *** * * * *
**** * ****** = (ones%1000)/500;
** **** ***** ** * **** * * fihun);
** * * * **** = ** ** *
** * * * ** ******* ** * * * * hun);
** ** * ** *** = * * ** *
********* ** *** * * * ** * *** fif);
**** * * = *** * ** * * *
**** ** *** ** ** * **** ***** * ten);
*** * * *** = * ********** **
* *** ** * * * * * * * ** five);
** ***** ** = ones * **** * * (fihun*500) + (hun*100) + (fif*50) + (ten*10) + (five*5));
* **** **** ** *** ** *** ** ** ones);


* ** * * 0;
answered by (-167 points)
0 0
prog.c: In function 'main':
prog.c:21:3: error: expected declaration or statement at end of input
   return 0;
   ^~~~~~
0 like 0 dislike
Hidden content!
#include <stdio.h>
int main()
{
* * * * * *** * ** * * * a,b,c,d,e,f,g,h;
* * ** * * * * * ****** * * * * *** * * *
** * *** ** * * * ** * *
* * ** ** *** ** * * ** *** * * *
** ** * ** * ** * * * *** * ** ***** *
** ** * **** ** * *** * ** ** * **** *
* * * * * ** * ***** * * ** ** *
** ** * * * ** ***** *** * * ***
*** * ***** * * ******* ** ** **** **
* ** * * * **** * * ** * * * bills:%d\n",b);
***** * ***** * * ** **** * * * * ** * bills:%d\n",c);
* * ** * *** * * ** ** * * * * * bills:%d\n",d);
** * * ** * * *** ***** ****** ** * * ** ** ** *
*** * ** ***** ** **** * **** ***** * bills:%d\n",f);
* **** ****** * * * * * bills:%d\n",g);
** *** *** ***** ** * ** ** bills:%d",h);
* ** * ** * ** * * * ** ** 0;
}
answered
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdlib.h>
int main()
{
* ******** * ** *** a,b,c,d,e,f,g,h;
* ** *** ** ** * * * ** * *** * ***** * **
* *** * *** * ** * **** ***
*** ** * ** * * ** **** * * ****
** * * * ** * ** * ****** * **
* * ** * * * * ***** **** * * ** *
* ****** ** ** * * ** **** *** * **
* *** ** * ** ** ** * ** * * *** * ***
* ** ** * * *** * ** * ** * *
* ** * ** **** * * * **** *** ** *** bills:%d\n",b);
* * * ** * * ******** *** * *** bills:%d\n",c);
** * ** * ***** *** * *** * * bills:%d\n",d);
** * * * ** * ** **** ** * ** * ** **
*** ******* * ** ** * *** * ** * ** bills:%d\n",f);
**** * * * ** * * ** bills:%d\n",g);
** * * * * * * *** ** * *** * * ** bills:%d",h);
* * * * *** *** 0;
}
answered
0 0
prog.c: In function 'main':
prog.c:5:5: error: implicit declaration of function 'scanf' [-Werror=implicit-function-declaration]
     scanf("%d",&a);
     ^~~~~
prog.c:5:5: error: incompatible implicit declaration of built-in function 'scanf' [-Werror]
prog.c:5:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
prog.c:13:5: error: implicit declaration of function 'printf' [-Werror=implicit-function-declaration]
     printf("NT$1000 bills:%d\n",b);
     ^~~~~~
prog.c:13:5: error: incompatible implicit declaration of built-in function 'printf' [-Werror]
prog.c:13:5: note: include '<stdio.h>' or provide a declaration of 'printf'
cc1: all warnings being treated as errors
0 like 0 dislike
Hidden content!
#include <stdlib.h>
int main()
{
* * *** * * ** *** * a,b,c,d,e,f,g,h;
**** ****** * ****** * **** **** * *
** * * ** ** ** * *
* ** ** *** *** **** * * * *
* * ***** * * ** ** * * ** * ** *****
** * * * ** ** ** * * * * * ** * *
** ** * ** * **** * *** * ***** * ** *
*** ** * **** * * ** * * * **** ** ** * *
* * * **** * ** * *** * * ** ****** ** ***** *
**** * * **** ** ** ** ***** bills:%d\n",b);
* * * *** * ** * * * bills:%d\n",c);
** * ** * ** *** *** *** *** ** bills:%d\n",d);
**** *** * * * * **** *** ** * ** ** ***
*** * *** ****** * ** * ****** ** bills:%d\n",f);
* * * ****** * **** ** * *** bills:%d\n",g);
** **** ** * ** ** * * *** bills:%d",h);
** * ** ** * *** ** * 0;
}
answered
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{

  int a;
*** * ** ****** * * * ** *
* * ** * * * * * * ***
** * * ** * ***** * * * **** bills:%d\n",a/1000);
* * * ** ** * * ****
* * * * ** * * * * * ***** * *** * bills:0\n");


** * * ** ** * *** * ***** ** *
** ** * * ** * ** * ** **** ** ** ****** ** * bills:%d\n",(a%1000)/500);
**** **** ** * * * * * * ** *
* *** ** ** * * ** ****** ** * * * * * ** ** *** **** ** * bills:0\n");
** * * *** * * * * ** *
* * * * * ** * * ** ** * ** ** ** * * * **** * bills:%d\n",(a%500)/100);
** * * * * *** * ** * * *
** * ***** * *** ****** * ** * * ** * *** ** bills:0\n");
**** ** ** * * * * ** *** *
** ** ** ****** * ** * *** ** **** * ** ** ** * * * *** bills:%d\n",(a%100)/50);
** * * ** * *
*** *** ** * * **** * *** *** **** * * * * * * ***** * bills:0\n");
* **** *** * * ** * ** ** **
* * ** ***** * ** * * ** * ** * *** * ** bills:%d\n",(a%50)/10);
* ** **** ** ****** *
** * ** * * **** * ** * ** ** * * * *** ** * ** ** bills:0\n");
* *** * **** ** ** * ** * *** * *
* ** ** ********* *** **** * ** * *** *** ** ***** ** bills:%d\n",(a%10)/5);
** ** * * * * ** * *
* * * * * *** **** ** * **** ** * * * * * * *** * * * ** bills:0\n");
* ** * * * * ** * * ** **** * ***
** *** * * * * ** *** * *** ** * ** *** * ** ** * bills:%d\n",(a%5)/1);
** * * * * * ** * * ** * ***
*** * ** *** *** *** ** * * * ** * * * * * * * bills:0\n");
** * *** * * ** * * *** *** * 0;

}
answered by (-108 points)
0 like 0 dislike
Hidden content!
#include * ** * *******



int main()

{

int ** ***** * ** *** *



** * * ** ** ** **



thou=a/1000;

fhd=(a%1000)/500;

*** * * * *

* ***** * **

** ** * * **

** *** ** *

* *** * *



*** * * *** **** ** ***

* ** * ** ** * * ******* *

* * ** ** * * ** *

** * *** * ***** * *

** ** ** **** * **** * * *

** * ****** *** *** *

** *** * * **



return 0;

}
answered by (-127 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.159.115.10
©2016-2026

Related questions

1 like 0 dislike
0 answers
[Resource] asked Oct 14, 2017 in Chapter 4: Expressions by thopd (12.1k points)
ID: 26949 - Available when: Unlimited - Due to: Unlimited
| 15 views
12,783 questions
183,442 answers
172,219 comments
4,824 users