In: Computer Science
C-Language
*Calculates the user's age in seconds.
*Estimate the number of times the person has sneezed in his/her lifetime (research on the Internet to obtain a daily estimate).
*Estimates the number of calories that the person has expended in his/her lifetime (research on the Internet to obtain a daily estimate).
*Also calculate the number of sandwiches (or other common food item) that equals that number of calories. Be creative: Pick other health-related statistic. Try searching the Internet to determine how to calculate that data, and create a program to perform that calculation. The program can ask the user to enter any information needed to perform the calculation.
Code template: C-Language
#include <stdio.h> int main(void) { int userAgeYears; int userAgeDays; int userAgeMinutes; int totalHeartbeats; int avgBeatsPerMinute = 72; printf("Enter your age in years: "); scanf("%d", &userAgeYears); userAgeDays = userAgeYears * 365; // Calculate days without leap years userAgeDays = userAgeDays + (userAgeYears / 4); // Add days for leap years printf("You are %d days old.\n", userAgeDays); userAgeMinutes = userAgeDays * 24 * 60; // 24 hours/day, 60 minutes/hour printf("You are %d minutes old.\n", userAgeMinutes); totalHeartbeats = userAgeMinutes * avgBeatsPerMinute; printf("Your heart has beat %d times.\n", totalHeartbeats); return 0; }
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
#include <stdio.h>
int main(void) {
int userAgeYears;
int userAgeDays;
int userAgeMinutes;
int totalHeartbeats;
int avgBeatsPerMinute = 72;
printf("Enter your age in years: ");
scanf("%d", &userAgeYears);
userAgeDays = userAgeYears * 365; // Calculate days without leap
years
userAgeDays = userAgeDays + (userAgeYears / 4); // Add days for
leap years
printf("You are %d days old.\n", userAgeDays);
userAgeMinutes = userAgeDays * 24 * 60; // 24 hours/day, 60
minutes/hour
printf("You are %d minutes old.\n", userAgeMinutes);
totalHeartbeats = userAgeMinutes * avgBeatsPerMinute;
printf("Your heart has beat %d times.\n", totalHeartbeats);
int sneeze=4*userAgeDays;
int calories=2663*userAgeDays;
int net=1300*userAgeDays+calories;
printf("Enter the calories of 1 sandwich: ");
int num;
scanf("%d",&num);
printf("Number of sandwiches needed are %d\n",net/num+1);
return 0;
}
Kindly revert for any queries
Thanks.