5 Questions
What is the purpose of the 'acceptUnitPrice' function in the code?
Accepts the unit price of the product
What does the 'computeDiscount' function in the code calculate?
Discount rate applied
What does the 'computeAmountPayable' function calculate in the code?
Total amount payable after discount
Which function in the code is responsible for accepting the quantity of the product?
acceptQty
What will be printed by the code at the end of its execution?
The amount payable is >> $amount
Study Notes
C Programming: Computing Amount Payable
- The program includes a constant
drate
set to 0.05, which represents a discount rate. - The function
acceptUnitPrice
takes afloat
input for the unit price and returns it. - The function
acceptQty
takes anint
input for the quantity and returns it. - The function
computeDiscount
calculates the discount by multiplying the unit price by the discount ratedrate
. - The function
computeDiscountedPrice
calculates the discounted price by subtracting the discount from the unit price. - The function
computeAmountPayable
calculates the total amount payable by multiplying the discounted price by the quantity. - The
main
function:- Prompts the user to enter the unit price and quantity.
- Calls the
acceptUnitPrice
andacceptQty
functions to get the input values. - Calculates the discount, discounted price, and amount payable using the other functions.
- Prints the resulting amount payable with two decimal places.
Test your knowledge of C programming functions with this quiz. The quiz includes questions about function definitions, parameter passing, and return types in C. See how well you understand concepts like function declarations, input/output parameters, and function calls.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free