Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have to modify this program to include a particular function to determine the number of galleons, sickles, and knuts for the amount of the

I have to modify this program to include a particular function to determine the number of galleons, sickles, and knuts for the amount of the total number of knuts.

This is the function I want to integrate into my code:

void convert(int total_knuts, int *galleons, int *sickles, int *knuts);

The galleons parameter points to a variable in which the function will store the number of galleons required. The sickles and knuts parameters are similar. Modify the main function so it calls convert to compute the smallest number of galleons, sickles, and knuts. The main function should display the result.

My code:

int main(void)

{

/*Variables*/

int knuts =0;

int sickles =0;

int galleons =0;

/*User is prompted to enter information here.*/

printf("Enter the number of knuts ");

scanf("%d", &knuts);

/*Input validation*/

while (knuts < 0 || knuts > 1000000000)

{

printf("Invalid amount Amount must be between 0 and 1000000000 ");

scanf("%d", &knuts);

}

/*Knuts are converted to sickles and galleons.*/

sickles = knuts/29;

galleons = knuts/17;

/*Information displayed.*/

printf("There are %d sickles and %d galleons in %d knuts ", sickles, galleons, knuts);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago