5 like 0 dislike
13.9k 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 | 13.9k views

69 Answers

0 like 0 dislike
Hidden content!
****** * * * * **** *
int main()
{
int a,b,c,d,e,f,g;
* * * * * ** * *** * * * ** * * ** ** * ******** *
** ** * * *** ** * ** * * * ** ** * ** * *****
** ** ** * ** * ** ** * * ** * *
* ***** * * **** ** ** *** *** ** *** bills:%d\n",b/500);
** * * * ***** ** ** * ********
*** * *** * * * **** * * * *** bills:%d\n",c/100);
** *** *** ** * * **** **
* * * * * ***** * * * ** * bills:%d\n",d/50);
*** *** * ** * *** *****
* * * * * ** * *** * ** * ** * * * bills:%d\n",e/10);
** * ** * *** ** ** * ** * *
* ** ** * *** ** * * * * *** * bills:%d\n",f/5);
* * *** * * **** * ** * *
*** *** ****** ** ** * ***** ** ** bills:%d",g);
****** * * *** ** 0;
}
answered by (64 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
** ***** ** * * *

int main()

{
int m,a,b,c,d,e,f,g;
**** * *** * **
a=m/1000;
if (m%1000>=500)
{
* * ** * * * **** ** * * *
* **** ***** *** * * * ** *
}
if (m%1000<500)
{
* ****** * * **
** * * ***** * * ***
}
if (m%100>=50)
{
* ** **** * **** * * * ***
**** *** * * ** * ** * *
}
if (m%100<50)
{
* **** * ***** ** * * *** ***
* * * *** *** * ** **** *****
}
if (m%10>=5)
{
* *** ** *** ** ** * * ***
* * *** ** ** * * * * ******
}
if (m%10<5)
{
*** * * * **** * * ** **** *
** ** ** * * *** ***
}
* **** ** **** * ** * ** *
** ** * * * * * **** *
** ** *** ****** * *
*** * ** * ** * * **** *****
** ** * * * *** * **
****** * * * * *
** * * ** * **** * **

}
answered by (-32 points)
edited by
0 0
prog.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int]
 main(void)
 ^~~~
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
prog.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int]
 main()
 ^~~~
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
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(){
* ** * * * *** n;
** * * *** * * **** * temp;
    
**** ** ***** * **** ** **** ** ** * ** *
    
    
*** * ** ** *** ** * * * *** * **** * *
* * ** * * * **** * * * * *** *** ** ** * ** ** ** * * bills:%d\n", temp);
* * ** * * ***** ** * * * ** * ** * * **
*** ***** ** * *** *** ****** * ** *** ** = n - temp*1000;
    
* ** * * ** ** *** *** ***** ** * * *** * = n/500;
**** * * ** ** * ** * *** * * *** * * **** * ** * ** ** **** bills:%d", temp);
* *** ** * *** * * ***** ** * * *
*** * * *** * ** * * ** * * * * * *** *** ** * = n - temp*500;
    
**** * * * * *** ** ** ** * * ** * ** ** * = n/100;
** ** * * * * * **** * *** * * * ** * bills:%d", temp);
** * ** ** * *** * *** * ** *** *
* * * * ** **** **** * *** *** **** ** * ** = n - temp*100;
* ** ***** **** * * ** ** ** * * ***** *
** *** * *** ** ** ** ** ******* *** * ** * * = n/50;
* * *** ** ** *** *** *** * * ** * *** ****** **** bills:%d", temp);
** **** **** * ** * * **** * *** ** * *
* * ** ** ** ** * *** *** * *** * *** * * ** * * = n - temp*50;
* ** * * * **** *** * * * *
* * * ***** * ** * ** ** ** * *** ** = n/10;
*** ** **** * * *** * * *** * ** ** *** **** ** * * * * bills:%d", temp);
* *** ** * ** ** * * * * ** **** * * *
* **** ** * * *** * * ** * * *** * ** ** = n - temp*10;
* * ** * * * * *** * * ** * * * * * * *** *
* ** * ** ** *** * **** * *** ** **** = n/5;
* ** ** ** ** ***** * * * ** * ** **** * * * * bills:%d", temp);
* * ** ** **** * * ** *** ** *** **
* ** * * * * * * *** * * * ** * *** = n - temp*5;
* ** * * *** ** ** *** * ****** *
* **** ** ** *** * * * * * ** * * *** ****** ** * = n/1;
* * *** ***** ** ** * * * ******** * * * *** ** * bills:%d", temp);
**** * *** * * *** *** * * * * * ** * ** *** = n - temp*1;
    
* ** **** * * ***** * * 0;
}
answered
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(){
*** * *** *** *** * ** *** ** n;
** * * * * temp;
    
** * * ** *** *** *** *** ** ** **** *
    
    
** * * * * *** * ** ** * ** ** *** ** * *
** * * * **** *** *** **** *** **** * * *** ** * bills:%d\n", temp);
* ** ** * * *** ** * *** * ****** * * ***
* * **** **** * *** * * *** * ** ** * * = n - temp*1000;
    
**** ** * * ** **** ***** *** * *** * **** ** = n/500;
** * * **** ** * **** * * * ** ** *** * ** ***** ** * * bills:%d", temp);
** ** * *** * * **** **** ** * *** * * ** *
** ** ** * * ****** * **** ******* **** ** = n - temp*500;
    
* **** *** ** * ** * * ** **** ** * *** * * = n/100;
*** ** * * ** ****** ** *** ** * ** ** * * ****** * * bills:%d", temp);
** * **** * *** **** ***** **** * ** *** *
** * ****** * ****** *** ** * ** * = n - temp*100;
** * * *** ** *** *** *** * * *** ****** ** *
***** * * ** * * * ** * * **** ** * * * = n/50;
*** *** * * * * *** * ** * *** * *** **** * ****** bills:%d", temp);
* ** *** ** ****** * ** * ** * * * *** * *
* *** **** * * *** * * *** * * ***** * * = n - temp*50;
* ** * *** * ** ** * ** * * *** **
*** * ** **** ** * **** * * * ** * ****** * *** = n/10;
** * * * *** *** * * * * * **** *** **** *** ** **** * bills:%d", temp);
* * * * * * * * ** * * * ** ** ** ******* *
****** * ** * ** * **** * * ** *** * ** = n - temp*10;
** * *** * * *** **** *** ***** * * * ***** ** * ***
* * ** ** * ** *** * * * * **** ** * * = n/5;
*** *** * * * ** * ** *** * * * * *** ** *** bills:%d", temp);
* * * *** ** * *** ****** * ***** ** * ** *
*** *** * ** *** * *** ** ***** ****** ** * = n - temp*5;
*** ** * * ****** * * * * * ** * ***
** ** * *** **** * ** ** ****** ******* ** * *** = n/1;
** *** * *** ***** * *** ** *** ** * ** * * * **** * * **** * bills:%d", temp);
    
* * * ***** **** ** 0;
answered
0 0
prog.c: In function 'main':
prog.c:43:5: error: expected declaration or statement at end of input
     return 0;
     ^~~~~~
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
* ***** * ** *** *** ** a,b=0,c=0,d=0;
***** *** * * *** *** ** * *** *** **** * *****
* *** * * ** **** ** * *** bills:%d\n",a/1000);
** * * ** ** * * **** *** ** ** ** ** bills:%d\n",a%1000/500);
** *** * ** ******** ** ** * *** **** bills:%d\n",a%1000%500/100);
* ** ** * **** * * ** * * * * **** * *** ** * *
** ** * *** * *** * * *** * *** * ** * * *** * *
* * * ***** * * ******** * * * ** ****** * * *
* ***** * ** ********* ** * * * * * * * ****** ** *
}
answered by (-214 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
*** * * * * * * * ********** amount;

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

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

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

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

* ** * * * ******** ** ** ** * ** ** bills:%d\n",amount/50);
** ** * ** * * ** ** *** **

* * * *** * **** ** * * * *** bills:%d\n",amount/10);
** * ** * * * * ** * * * * * *

* * * * * * ***** * **** * * * * * bills:%d\n",amount/5);
*** ** * ** * ** *** ** *

* ** ** **** * **** ** * * bills:%d",amount/1);
** **** * *** * * * **

*** ** * * ** * ** ** * ** 0;
}
answered by (-16 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()
{
******* * ** * a,b,c,d,e,f,g,h;
**** * **** ** * ******* * ** ** ** ** * * **** *
* ** * * *** ** * * *** ** * *** *
*** * * ****** * * *****
* * * *** *** ********* * *
* ***** *** *** * * * * * **
***** *** ** * * ** *
* * ** **** **** * ******* *
* ** * ***** ****** * * * ** ***
* ** * *** * * * ** ** * *
** * * * * ** *** ** ***
* * * *** * *** * *** * **
***** * ** * *** ***
* * * * * * * ** ** *
* * * ** *** * * ******
* **** * * * * ** ** * ** *** ** ** bills:%d\n",b);
* *** * * * * * *********** ** * *** bills:%d\n",c);
* ** * * * * * *** * * * * ** * * * * bills:%d\n",d);
* ** ** * * * * ** * ** *** ** * * bills:%d\n",e);
** ** * * *** * * ** ** * * bills:%d\n",f);
** * ** * * * *** * ******** * bills:%d\n",g);
* ** **** * * ****** * * bills:%d",h);
* *** * *** * ** ** * 0;
}
answered by (-229 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
* *** **** * a;
* **** **** * * ****** ********* *** ** *****
**** **** ** * * ********* bills:%d\n",a/1000);
*** ** *** * * *** ** ** * ** * * * **** ****
** ** *** *** * * * *** * * * ** * ** ** * * * ***
** ** *** *** ** * ** ** ***** * * * ** ****
** *** ** **** ** ** ** * * * * *** * ** ** ** * **
* *** * * * **** ***** * * *** ** *** ** * * *
* * * * * * ** ** **** * ** bills:%d",a%5);
** *** *** * ** *** 0;
}
answered by (-498 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()

{
* * * ** * ** * ** * *** ******* * ** ** *
* ** *** ************ * ** * ****** * * * *

**** * * *** * * ** * * * ***** * ** * * *** * *
* *** ** * *** ** * ** ** *
* ** * * * * ***** ** ** **** ** * bills:%d\n",input/500);
* ** *** ***** * ** * ***
* ** ***** *** * * * * * * * * *** * ** * ** * *
** ***** * ** * * ** * *
* * * *** * * ** ********** **** *** bills:%d\n",input/50);
** *** * *** * * *
** **** * * ** * * * ** ** ** *** ** bills:%d\n",input/10);
************ *** * *** **
* * * ** ** ***** * * * * * bills:%d\n",input/5);
**** * * *** * **** * *
** ***** * * * *** * * * * **** ** ** *** bills:%d",input/1);

* ** ** ******* * * 0;

}
answered by (-249 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()
{
* ** * **** * **** * ** a,b,c,d,e,f,g,h;
** ** * * ** ** * * * **** * * * ****
* * ** * ** ** * * *
* * * *** ** * ** * *
** * * ** ** ** ** * * ***
* *** ** * *** ** ** * *** **** **
* ** *** ** * * * *** *** * * *** *
** *** * * * * * ** * * *** * ** ** ** ** *
* *** * * ** * * * **** **** ** * ** ** *
* *** * * * * * ******** ** * **** bills:%d\n",b);
* ** ** * * *** ***** *** * * bills:%d\n",c);
**** *** ** ** * * *** ** ** * * ** bills:%d\n",d);
** ** ****** * ** * * ***** * * bills:%d\n",e);
* **** * * * ** * ** ***** ** bills:%d\n",f);
* * ***** ** * *** * ** * bills:%d\n",g);
** * **** * ** ** * * *** * * * * bills:%d",h);
}
answered by (-329 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.197.65
©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