Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please write a program in basic c and explain what each line of code means. Writ

ID: 3548796 • Letter: P

Question

please write a program in basic c and explain what each line of code means.

Write a program that includes a function hotwheels() that will accept a floating-point number total and the addresses of the integer variables cars, trucks, boats, atvs. The passed floating-point number represents the total amount of money to be spent on hotwheels. The function is to determine the quantity of cars, trucks, boats, and atvs that can be purchased, writing these values directly into the respective variables declared in the calling function.

This function will be called from the main program and when it returns to main, it will print out the values of cars, trucks, boats, and atvs.

price list of different hotwheels:

1.cars--$1.00 each

2.trucks--$0.50 each

3.boats--$0.25 each

4.atvs--$0.01 each

For example, if I enter a total amount of money of $3.78, I can buy the following hotwheels:

3 cars

1 truck

1 boat

3 atv

Explanation / Answer

// header file to access input and output
#include<stdio.h>
void hotwheels(float total,int *cars,int *trucks,int *boats,int *atvs)
{
total = total*100;
*cars = (total/100);
total = total - (*cars)*100;
*trucks = total/50;
total = total - (*trucks)*50;
*boats = total/25;
*atvs = total - (*boats)*25;
}
int main()
{
int cars = 0;
int trucks =0;
int boats =0;
int atvs = 0;
float total =0;
printf(" Enter total amount of moeny ");
scanf("%f",&total);
hotwheels(total, &cars, &trucks, &boats,&atvs);
printf(" I can buy the following hotwheels:");
printf(" %d cars %d truck %d boat %d atv ",cars,trucks,boats,atvs);
return 0;
}