Question

In: Computer Science

C-Language *Calculates the user's age in seconds. *Estimate the number of times the person has sneezed...

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;
}

Solutions

Expert Solution

`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.


Related Solutions

C++ Read first a user's given name followed by the user's age from standard input. Then...
C++ Read first a user's given name followed by the user's age from standard input. Then use an ofstream object named outdata (which you must declare) to write this information separated by a space into a file called outdata. Assume that this is the extent of the output that this program will do. Declare any variables that you need.
Write a RIMS-compatible C-language for-loop that counts the number of times a bit of A is...
Write a RIMS-compatible C-language for-loop that counts the number of times a bit of A is followed by a bit of the opposite parity (01 or 10) and writes the value to B. For example 00100110 has 4 cases: 00100110, 00100110, 00100110, 00100110.
c# language Create a class “Person” which included first name, last name, age, gender, salary, and...
c# language Create a class “Person” which included first name, last name, age, gender, salary, and havekids (Boolean) variables. You have to create constructors and prosperities for the class. Create a “MatchingDemo” class. In the main function, the program reads the number of people in the database from the “PersonInfo.txt” file and creates a dynamic array of the object. It also reads the people's information from “PersonInfo.txt” file and save them into the array. Give the user the ability to...
Make a C++ program that reads the age of a person, if the person is between...
Make a C++ program that reads the age of a person, if the person is between 12 and 17 years old, a message that says "Teenager!" otherwise print "Not a teenager."
Write a program in C that prompts the user for a number of seconds and then...
Write a program in C that prompts the user for a number of seconds and then converts it to h:m:s format. Example: 5000 seconds should display as 1:23:20 (1 hour, 23 minutes, 20 seconds.) Test with several values between about 100 seconds and 10,000 seconds. use unint and remainders for this and keep it as simple as possible.
Write a program that calculates the compound interest for an investment. (C++ coding language) If you...
Write a program that calculates the compound interest for an investment. (C++ coding language) If you deposit an amount of money P , the principal, at an interest rate r then the interest will compound over time. This means that the interest earned each period becomes part of the principal and the next time you get interest you earn interest on the interest. This is known as compounding. The equation for compound interest is ( r)n·t Pn=P0 1+n where P0...
I believe that the number of times a person will yawn in a day is normally...
I believe that the number of times a person will yawn in a day is normally distributed, with a standard deviation of 3. If I do a study of 36 random individuals, and they have an average of 12 daily yawns with a standard deviation of 3.6, find a 99% confidence interval for the standard deviation in the number of daily yawns for the population of all people.
Are the mean number of times a month a person eats out the same for whites,...
Are the mean number of times a month a person eats out the same for whites, blacks, Hispanics and Asians? White Black Hispanic Asian 6 4 7 8 8 1 3 3 2 5 5 5 4 2 4 1 6 6 7 df numerator and denominator = Write Ho and Ha What is the p-value? Do you reject or accept the null hypothesis at the 5% level?
Write a C program that calculates the average grade for a specified number of students from...
Write a C program that calculates the average grade for a specified number of students from each student's test1 and test2 grades. The program must first ask the user how many students there are. Then, for each student, the program will ask the user for the test1 grade (grade #1) and test2 grade (grade #2). The program should be able to handle up to 100 students, each with 2 grades (test1 and test2). Use a two-dimensional float array to store...
Create a C++ program which will accept an unlimited number of scores and calculates the average...
Create a C++ program which will accept an unlimited number of scores and calculates the average score. You will also need to prompt for the total points possible. Assume each test is worth 100 points. Requirements. • Enter the Student ID first, then prompt for grades. Keep prompt- ing for grades until the client enters ’calc’. That triggers final pro- cessing. • Make your code as reliable as possible. • Make your program output easy to read. • You cannot...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT