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

***This must be done in Visual Studio 2010 and use only #include <stdio.h> and #

ID: 3694895 • Letter: #

Question

***This must be done in Visual Studio 2010 and use only #include <stdio.h> and #include stdafx.h as we use a basic library.***
Write a program to do the following:
Ask the user to enter the number of participants
Use a while loop to ask each participant 3 questions: "Enter the number of calories you ate for breakfast: ", "Enter the number of calories you ate for lunch: ", and "Enter the number of calories you ate for dinner: ". Read in each of these values.
Total the number of calories consumed for the day and print a message to the screen: "You have consumed ## calories today.".
If the total calories is less than or equal to 2000, print another message: "You are within the 2000 calorie limit- good job!" else print "Whoops you are over the calorie limit for the day!".
Don't forget to add a line at the very top: #include "stdafx.h" (needed for Visual Studio software).

Explanation / Answer

I wrote this program for normal console, you can convert into Visual Studio 2010 IDE

Programme:

#include <stdio.h>

int main()
{
char res;
int breakfast,lunch,dinner,total;
  
printf("Enter the number of calories you ate for breakfast:");
scanf("%d", &breakfast);

printf("Enter the number of calories you ate for lunch:");
scanf("%d", &lunch);

printf("Enter the number of calories you ate for dinner:");
scanf("%d", &dinner);

total=breakfast+lunch+dinner;
printf(" You have consumed %d calories today ", total);
  
if(total<=2000)
printf(" You are within the 2000 calorie limit- good job! ");
else
printf(" Whoops you are over the calorie limit for the day! ");
return 0;
}

Output:

Enter the number of calories you ate for breakfast: 500

Enter the number of calories you ate for lunch: 1200

Enter the number of calories you ate for dinner:250

You have consumed 1950 calories today

You are within the 2000 calorie limit- good job!