Answer:
// program in C.
#include <stdio.h>
// function to calculate calories burned
double calories_burned(int age,double weight,double heart_rate,int i_time, char gen)
{
// variable
double calories=0;
if(gen=='m')
// calories burned by men
calories = ((age * 0.2017 )- (weight * 0.09036) + (heart_rate * 0.6309) - 55.0969) * (i_time / 4.184);
else if(gen=='f')
// calories burned by Women
calories = ((age * 0.074) - (weight * 0.05741) + (heart_rate * 0.4472) - 20.4022) * (i_time / 4.184);
// return calories burned
return calories;
}
// main function
int main()
{
// variables
int u_age;
double u_weight,heart_rate;
int i_time;
printf("Enter age (years):");
// read age
scanf("%d",&u_age);
printf("Enter weight (pounds):");
// read weight
scanf("%lf",&u_weight);
printf("Enter heart rate (beats per minute):");
// read heart_rate
scanf("%lf",&heart_rate);
printf("Enter time (minutes):");
// read time
scanf("%d",&i_time);
// call function for men
double men_cal=calories_burned(u_age,u_weight,heart_rate,i_time,'m');
// call function for women
double women_cal=calories_burned(u_age,u_weight,heart_rate,i_time,'f');
// print calories burned by men
printf("Men calories burned :%0.2lf \\", men_cal);
// print calories burned by Women
printf("Women calories burned :%0.2lf \\", women_cal);
return 0;
}
Step-by-step explanation:
Read age, weight, heart rate and time from user.Then call the function calories_burned() with all the input and a character parameter for men.This function will calculate the total calories burned by the men.Similarly call the function again for women, Then it will return the calories burned by women.Print the calories burned by men and women.
Output:
Enter age (years):20
Enter weight (pounds):175
Enter heart rate (beats per minute):144
Enter time (minutes):60
Men calories burned :343.79
Women calories burned :508.05