Final answer:
To design a C program that prompts the user for the number of cookies eaten and displays the total number of calories consumed, you can follow these steps.
Step-by-step explanation:
To design a C program that prompts the user for the number of cookies eaten and displays the total number of calories consumed, you can follow these steps:
- Declare a variable to store the number of cookies eaten.
- Prompt the user to enter the number of cookies and store it in the variable.
- Calculate the total number of calories by multiplying the number of cookies by the number of calories per cookie. You can assume a fixed number of calories per cookie.
- Display the total number of calories consumed to the user.
Here's an example code snippet to demonstrate this:
#include <stdio.h>
int main() {
int cookiesEaten;
int caloriesPerCookie = 50; // Assume each cookie has 50 calories
int totalCalories;
printf("Enter the number of cookies eaten: ");
scanf("%d", &cookiesEaten);
totalCalories = cookiesEaten * caloriesPerCookie;
printf("Total calories consumed: %d\\", totalCalories);
return 0;
}