SlideShare a Scribd company logo
Computing Change C program Computing Change Write a program p3.c that computes the
equivalent of a dollar amount in change using quarters, dimes, and pennies. No nickels are used
for conversion. For this problem you need to write the top-down algorithm. The main function
program reads from the terminal in a loop while not end-of-file the dollar amounts. Inside the
loop it calls function getChange() that computes how many quarters, dimes, and pennies make up
the original dollar amount. The getChange() function has the following formal parameters (in
this order): double dollarAmount: the total amount in $ pointer to int pQuarters that will store
the number of quarters pointer to int pDimes that will store the number of dimes pointer to int
pPennies that will store the number of pennies The getChange() function computes the change
and then returns the total number of coins. If dollarAmount
Solution
#include
// Converts the dollar amount to quarters, dimes and pennies
void getChange(double dollarAmount, int *pQuarters, int *pDimes, int *pPennies)
{
if(dollarAmount < 0)
{
const int QUARTER_TO_CENTS = 25;
const int DIME_TO_CENTS = 10;
const int PENNY_TO_CENTS = 1;
//Convert user entered amount to cents
int amountToCents = dollarAmount * 100;
//Start conversion
*pQuarters = amountToCents / QUARTER_TO_CENTS;
amountToCents = amountToCents % QUARTER_TO_CENTS;
*pDimes = amountToCents / DIME_TO_CENTS;
amountToCents = amountToCents % DIME_TO_CENTS;
*pPennies = amountToCents;
}
*pQuarters = -1;
}
int main()
{
double dollarAmount;
int pQuarters, pDimes, pPennies;
while(!feof(stdin))
{
// Get user input
scanf("%lf", &dollarAmount);
// Convert dollar amount
getChange(dollarAmount, &pQuarters, &pDimes, &pPennies);
if(pQuarters != -1)
{
printf(" $%lf makes %d quarters, %d dimes, and %d pennies (%d coins), total amount in coins:
$%lf. ",
dollarAmount, pQuarters, pDimes, pPennies, (pQuarters + pDimes + pPennies), dollarAmount);
}
else
{
printf(" Invalid input. ");
}
}
return 0;
}

More Related Content

Similar to Computing Change C program Computing Change Write a program p3.c th.pdf

CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
C++ Homework Help
 
C++ Homework Help
C++ Homework HelpC++ Homework Help
C++ Homework Help
C++ Homework Help
 
L03vars
L03varsL03vars
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
RSathyaPriyaCSEKIOT
 
java or oops class not in kerala polytechnic 4rth semester nots j
java or oops class not in kerala polytechnic  4rth semester nots jjava or oops class not in kerala polytechnic  4rth semester nots j
java or oops class not in kerala polytechnic 4rth semester nots j
ishorishore
 
C Programming
C ProgrammingC Programming
C Programming
Raj vardhan
 
Advanced C - Part 2
Advanced C - Part 2Advanced C - Part 2
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
vrickens
 
Basic c# cheat sheet
Basic c# cheat sheetBasic c# cheat sheet
Basic c# cheat sheet
Ahmed Elshal
 
C++ Overview
C++ OverviewC++ Overview
C++ Overviewkelleyc3
 
C++ lecture 01
C++   lecture 01C++   lecture 01
C++ lecture 01
HNDE Labuduwa Galle
 
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
Blue Elephant Consulting
 
Intro To C++ - Class 11 - Converting between types, formatting floating point...
Intro To C++ - Class 11 - Converting between types, formatting floating point...Intro To C++ - Class 11 - Converting between types, formatting floating point...
Intro To C++ - Class 11 - Converting between types, formatting floating point...
Blue Elephant Consulting
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
ziyadaslanbey
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
Salahaddin University-Erbil
 
03b loops
03b   loops03b   loops
03b loops
Manzoor ALam
 

Similar to Computing Change C program Computing Change Write a program p3.c th.pdf (20)

CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
C++ Homework Help
C++ Homework HelpC++ Homework Help
C++ Homework Help
 
Chapter2
Chapter2Chapter2
Chapter2
 
L03vars
L03varsL03vars
L03vars
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
 
java or oops class not in kerala polytechnic 4rth semester nots j
java or oops class not in kerala polytechnic  4rth semester nots jjava or oops class not in kerala polytechnic  4rth semester nots j
java or oops class not in kerala polytechnic 4rth semester nots j
 
C Programming
C ProgrammingC Programming
C Programming
 
Advanced C - Part 2
Advanced C - Part 2Advanced C - Part 2
Advanced C - Part 2
 
Project two c++ tutorial
Project two c++ tutorialProject two c++ tutorial
Project two c++ tutorial
 
C++ programming
C++ programmingC++ programming
C++ programming
 
C programming
C programmingC programming
C programming
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
 
Basic c# cheat sheet
Basic c# cheat sheetBasic c# cheat sheet
Basic c# cheat sheet
 
C++ Overview
C++ OverviewC++ Overview
C++ Overview
 
C++ lecture 01
C++   lecture 01C++   lecture 01
C++ lecture 01
 
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
 
Intro To C++ - Class 11 - Converting between types, formatting floating point...
Intro To C++ - Class 11 - Converting between types, formatting floating point...Intro To C++ - Class 11 - Converting between types, formatting floating point...
Intro To C++ - Class 11 - Converting between types, formatting floating point...
 
Presentation 2 (1).pdf
Presentation 2 (1).pdfPresentation 2 (1).pdf
Presentation 2 (1).pdf
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
 
03b loops
03b   loops03b   loops
03b loops
 

More from ederstevensc52755

GENERAL LEDGERName BANK ACCOUNTAcct No. 100DateDetailsPo.pdf
GENERAL LEDGERName BANK ACCOUNTAcct No. 100DateDetailsPo.pdfGENERAL LEDGERName BANK ACCOUNTAcct No. 100DateDetailsPo.pdf
GENERAL LEDGERName BANK ACCOUNTAcct No. 100DateDetailsPo.pdf
ederstevensc52755
 
Does the rate of diffusion change over time Does the rat.pdf
Does the rate of diffusion change over time   Does the rat.pdfDoes the rate of diffusion change over time   Does the rat.pdf
Does the rate of diffusion change over time Does the rat.pdf
ederstevensc52755
 
Ellen baked 112 cookies and shared them equally with her 23 classmat.pdf
Ellen baked 112 cookies and shared them equally with her 23 classmat.pdfEllen baked 112 cookies and shared them equally with her 23 classmat.pdf
Ellen baked 112 cookies and shared them equally with her 23 classmat.pdf
ederstevensc52755
 
Compare the nurse cells (Sertoli cells) in the mammalian testis with.pdf
Compare the nurse cells (Sertoli cells) in the mammalian testis with.pdfCompare the nurse cells (Sertoli cells) in the mammalian testis with.pdf
Compare the nurse cells (Sertoli cells) in the mammalian testis with.pdf
ederstevensc52755
 
Below is a mutant Drosophila cuticle. What class (ex. segment polari.pdf
Below is a mutant Drosophila cuticle. What class (ex. segment polari.pdfBelow is a mutant Drosophila cuticle. What class (ex. segment polari.pdf
Below is a mutant Drosophila cuticle. What class (ex. segment polari.pdf
ederstevensc52755
 
An _ is found on the tRNA molecule and has the complementary bases to.pdf
An _ is found on the tRNA molecule and has the complementary bases to.pdfAn _ is found on the tRNA molecule and has the complementary bases to.pdf
An _ is found on the tRNA molecule and has the complementary bases to.pdf
ederstevensc52755
 
A psychiatrist wants to test the impact of a new drug designed to in.pdf
A psychiatrist wants to test the impact of a new drug designed to in.pdfA psychiatrist wants to test the impact of a new drug designed to in.pdf
A psychiatrist wants to test the impact of a new drug designed to in.pdf
ederstevensc52755
 
With respect to accounting for inventories, which of the following i.pdf
With respect to accounting for inventories, which of the following i.pdfWith respect to accounting for inventories, which of the following i.pdf
With respect to accounting for inventories, which of the following i.pdf
ederstevensc52755
 
Why would it be advantageous to be able to become an endospore if you.pdf
Why would it be advantageous to be able to become an endospore if you.pdfWhy would it be advantageous to be able to become an endospore if you.pdf
Why would it be advantageous to be able to become an endospore if you.pdf
ederstevensc52755
 
What is the protocol that can be used to create VPN connections betw.pdf
What is the protocol that can be used to create VPN connections betw.pdfWhat is the protocol that can be used to create VPN connections betw.pdf
What is the protocol that can be used to create VPN connections betw.pdf
ederstevensc52755
 
What factor has held up the development of an Intermediate Moisture .pdf
What factor has held up the development of an Intermediate Moisture .pdfWhat factor has held up the development of an Intermediate Moisture .pdf
What factor has held up the development of an Intermediate Moisture .pdf
ederstevensc52755
 
What is black holeSolutionA black hole is a region in space w.pdf
What is black holeSolutionA black hole is a region in space w.pdfWhat is black holeSolutionA black hole is a region in space w.pdf
What is black holeSolutionA black hole is a region in space w.pdf
ederstevensc52755
 
We are interested in determining whether scale traits for the Rio Gr.pdf
We are interested in determining whether scale traits for the Rio Gr.pdfWe are interested in determining whether scale traits for the Rio Gr.pdf
We are interested in determining whether scale traits for the Rio Gr.pdf
ederstevensc52755
 
The Reynolds number, pVDmu is a very Important parameter In fluid me.pdf
The Reynolds number, pVDmu is a very Important parameter In fluid me.pdfThe Reynolds number, pVDmu is a very Important parameter In fluid me.pdf
The Reynolds number, pVDmu is a very Important parameter In fluid me.pdf
ederstevensc52755
 
The respiratory gases of animals are. oxygen and nitrogen.nitrog.pdf
The respiratory gases of animals are. oxygen and nitrogen.nitrog.pdfThe respiratory gases of animals are. oxygen and nitrogen.nitrog.pdf
The respiratory gases of animals are. oxygen and nitrogen.nitrog.pdf
ederstevensc52755
 
The highest concentration of power regarding US monetary policy rest.pdf
The highest concentration of power regarding US monetary policy rest.pdfThe highest concentration of power regarding US monetary policy rest.pdf
The highest concentration of power regarding US monetary policy rest.pdf
ederstevensc52755
 
2.) Explain the originevolution of viruses by these hypotheses red.pdf
2.) Explain the originevolution of viruses by these hypotheses red.pdf2.) Explain the originevolution of viruses by these hypotheses red.pdf
2.) Explain the originevolution of viruses by these hypotheses red.pdf
ederstevensc52755
 
Suppose 13 of American adults believe that the highest priority of .pdf
Suppose 13 of American adults believe that the highest priority of .pdfSuppose 13 of American adults believe that the highest priority of .pdf
Suppose 13 of American adults believe that the highest priority of .pdf
ederstevensc52755
 
Revised QuestionThe entire content of the page has been enclosed .pdf
Revised QuestionThe entire content of the page has been enclosed .pdfRevised QuestionThe entire content of the page has been enclosed .pdf
Revised QuestionThe entire content of the page has been enclosed .pdf
ederstevensc52755
 
Priority queues may to implemented as linked lists kept in key or.pdf
Priority queues may to implemented as linked lists kept in key or.pdfPriority queues may to implemented as linked lists kept in key or.pdf
Priority queues may to implemented as linked lists kept in key or.pdf
ederstevensc52755
 

More from ederstevensc52755 (20)

GENERAL LEDGERName BANK ACCOUNTAcct No. 100DateDetailsPo.pdf
GENERAL LEDGERName BANK ACCOUNTAcct No. 100DateDetailsPo.pdfGENERAL LEDGERName BANK ACCOUNTAcct No. 100DateDetailsPo.pdf
GENERAL LEDGERName BANK ACCOUNTAcct No. 100DateDetailsPo.pdf
 
Does the rate of diffusion change over time Does the rat.pdf
Does the rate of diffusion change over time   Does the rat.pdfDoes the rate of diffusion change over time   Does the rat.pdf
Does the rate of diffusion change over time Does the rat.pdf
 
Ellen baked 112 cookies and shared them equally with her 23 classmat.pdf
Ellen baked 112 cookies and shared them equally with her 23 classmat.pdfEllen baked 112 cookies and shared them equally with her 23 classmat.pdf
Ellen baked 112 cookies and shared them equally with her 23 classmat.pdf
 
Compare the nurse cells (Sertoli cells) in the mammalian testis with.pdf
Compare the nurse cells (Sertoli cells) in the mammalian testis with.pdfCompare the nurse cells (Sertoli cells) in the mammalian testis with.pdf
Compare the nurse cells (Sertoli cells) in the mammalian testis with.pdf
 
Below is a mutant Drosophila cuticle. What class (ex. segment polari.pdf
Below is a mutant Drosophila cuticle. What class (ex. segment polari.pdfBelow is a mutant Drosophila cuticle. What class (ex. segment polari.pdf
Below is a mutant Drosophila cuticle. What class (ex. segment polari.pdf
 
An _ is found on the tRNA molecule and has the complementary bases to.pdf
An _ is found on the tRNA molecule and has the complementary bases to.pdfAn _ is found on the tRNA molecule and has the complementary bases to.pdf
An _ is found on the tRNA molecule and has the complementary bases to.pdf
 
A psychiatrist wants to test the impact of a new drug designed to in.pdf
A psychiatrist wants to test the impact of a new drug designed to in.pdfA psychiatrist wants to test the impact of a new drug designed to in.pdf
A psychiatrist wants to test the impact of a new drug designed to in.pdf
 
With respect to accounting for inventories, which of the following i.pdf
With respect to accounting for inventories, which of the following i.pdfWith respect to accounting for inventories, which of the following i.pdf
With respect to accounting for inventories, which of the following i.pdf
 
Why would it be advantageous to be able to become an endospore if you.pdf
Why would it be advantageous to be able to become an endospore if you.pdfWhy would it be advantageous to be able to become an endospore if you.pdf
Why would it be advantageous to be able to become an endospore if you.pdf
 
What is the protocol that can be used to create VPN connections betw.pdf
What is the protocol that can be used to create VPN connections betw.pdfWhat is the protocol that can be used to create VPN connections betw.pdf
What is the protocol that can be used to create VPN connections betw.pdf
 
What factor has held up the development of an Intermediate Moisture .pdf
What factor has held up the development of an Intermediate Moisture .pdfWhat factor has held up the development of an Intermediate Moisture .pdf
What factor has held up the development of an Intermediate Moisture .pdf
 
What is black holeSolutionA black hole is a region in space w.pdf
What is black holeSolutionA black hole is a region in space w.pdfWhat is black holeSolutionA black hole is a region in space w.pdf
What is black holeSolutionA black hole is a region in space w.pdf
 
We are interested in determining whether scale traits for the Rio Gr.pdf
We are interested in determining whether scale traits for the Rio Gr.pdfWe are interested in determining whether scale traits for the Rio Gr.pdf
We are interested in determining whether scale traits for the Rio Gr.pdf
 
The Reynolds number, pVDmu is a very Important parameter In fluid me.pdf
The Reynolds number, pVDmu is a very Important parameter In fluid me.pdfThe Reynolds number, pVDmu is a very Important parameter In fluid me.pdf
The Reynolds number, pVDmu is a very Important parameter In fluid me.pdf
 
The respiratory gases of animals are. oxygen and nitrogen.nitrog.pdf
The respiratory gases of animals are. oxygen and nitrogen.nitrog.pdfThe respiratory gases of animals are. oxygen and nitrogen.nitrog.pdf
The respiratory gases of animals are. oxygen and nitrogen.nitrog.pdf
 
The highest concentration of power regarding US monetary policy rest.pdf
The highest concentration of power regarding US monetary policy rest.pdfThe highest concentration of power regarding US monetary policy rest.pdf
The highest concentration of power regarding US monetary policy rest.pdf
 
2.) Explain the originevolution of viruses by these hypotheses red.pdf
2.) Explain the originevolution of viruses by these hypotheses red.pdf2.) Explain the originevolution of viruses by these hypotheses red.pdf
2.) Explain the originevolution of viruses by these hypotheses red.pdf
 
Suppose 13 of American adults believe that the highest priority of .pdf
Suppose 13 of American adults believe that the highest priority of .pdfSuppose 13 of American adults believe that the highest priority of .pdf
Suppose 13 of American adults believe that the highest priority of .pdf
 
Revised QuestionThe entire content of the page has been enclosed .pdf
Revised QuestionThe entire content of the page has been enclosed .pdfRevised QuestionThe entire content of the page has been enclosed .pdf
Revised QuestionThe entire content of the page has been enclosed .pdf
 
Priority queues may to implemented as linked lists kept in key or.pdf
Priority queues may to implemented as linked lists kept in key or.pdfPriority queues may to implemented as linked lists kept in key or.pdf
Priority queues may to implemented as linked lists kept in key or.pdf
 

Recently uploaded

Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 

Recently uploaded (20)

Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 

Computing Change C program Computing Change Write a program p3.c th.pdf

  • 1. Computing Change C program Computing Change Write a program p3.c that computes the equivalent of a dollar amount in change using quarters, dimes, and pennies. No nickels are used for conversion. For this problem you need to write the top-down algorithm. The main function program reads from the terminal in a loop while not end-of-file the dollar amounts. Inside the loop it calls function getChange() that computes how many quarters, dimes, and pennies make up the original dollar amount. The getChange() function has the following formal parameters (in this order): double dollarAmount: the total amount in $ pointer to int pQuarters that will store the number of quarters pointer to int pDimes that will store the number of dimes pointer to int pPennies that will store the number of pennies The getChange() function computes the change and then returns the total number of coins. If dollarAmount Solution #include // Converts the dollar amount to quarters, dimes and pennies void getChange(double dollarAmount, int *pQuarters, int *pDimes, int *pPennies) { if(dollarAmount < 0) { const int QUARTER_TO_CENTS = 25; const int DIME_TO_CENTS = 10; const int PENNY_TO_CENTS = 1; //Convert user entered amount to cents int amountToCents = dollarAmount * 100; //Start conversion *pQuarters = amountToCents / QUARTER_TO_CENTS; amountToCents = amountToCents % QUARTER_TO_CENTS; *pDimes = amountToCents / DIME_TO_CENTS; amountToCents = amountToCents % DIME_TO_CENTS; *pPennies = amountToCents; } *pQuarters = -1; } int main() {
  • 2. double dollarAmount; int pQuarters, pDimes, pPennies; while(!feof(stdin)) { // Get user input scanf("%lf", &dollarAmount); // Convert dollar amount getChange(dollarAmount, &pQuarters, &pDimes, &pPennies); if(pQuarters != -1) { printf(" $%lf makes %d quarters, %d dimes, and %d pennies (%d coins), total amount in coins: $%lf. ", dollarAmount, pQuarters, pDimes, pPennies, (pQuarters + pDimes + pPennies), dollarAmount); } else { printf(" Invalid input. "); } } return 0; }