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 should only use #include <stdio.h>*

ID: 3688042 • Letter: #

Question

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

Write a program to ask the user to enter the number of program participants. Then it should 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: ". Then it should total the number of calories consumed for the day and print a message to the screen: "You have consumed ## calories today.". Then 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"

Explanation / Answer

#include<stdio.h>
void main()
{
int pp,bf,lu,di;
int tot;
int i=1;
printf("enter the number of program participants");
scanf("%d",pp);
   while(i<=pp)
       {
printf("Enter the number of calories you ate for breakfast: ");
scanf("%d",bf);
printf("Enter the number of calories you ate for Lunch: ");
scanf("%d",lu);
printf("Enter the number of calories you ate for Dinner: ");
scanf("%d",di);
tot=pp+bf+lu;
printf("You have consumed %d calories today",tot);

       if(tot<=2000)
           {
               printf("You are within the 2000 calorie limit- good job!");
           }
       else
           {
               printf("Whoops you are over the calorie limit for the day!");
           }
i++;
       }
}