Need Help - Urgent

0 votes
asked Sep 29, 2018 by Qibs (270 points)
So this is the output im getting:

https://imgur.com/TUbx2Ze

I need to get this:

https://imgur.com/K9qg5Ra

So you can see after I type in the 5 it goes right to giving me the average. So can someone take a look at my code and see why the last two text wont show for me to add my last inputs in.

CODE:‚Äč

#define _CRT_SECURE_NO_WARNINGS

// Put your code below:

#include <stdio.h>

#define NUMS 3

int main(void) {

int high;

int low;

int highestd;

int highest = -42;

int highd = -1;

int lowd = -1;

int lowest = 42;

int totalhigh = 0;

int totallow = 0;

double average;

int i;

printf("---=== IPC Temperature Analyzer ===---\n");

for (i = 0; i < 3; i++)

{

printf("Enter the high value for day %d: ", i + 1);

scanf("%d", &high);

printf("\n");

printf("Enter the low value for day %d: ", i + 1);

scanf("%d", &low);

printf("\n");

while (high < low) {

printf("Enter the high value for day %d: ", i + 1);

scanf("%d", &high);

printf("\n");

printf("Enter the low value for day %d: ", i + 1);

scanf("%d", &low);

printf("\n");

}

while (high >= 41) {

printf("Enter the high value for day %d: ", i + 1);

scanf("%d", &high);

printf("\n");

printf("Enter the low value for day %d: ", i + 1);

scanf("%d", &low);

printf("\n");

}

while (low < -41) {

printf("Enter the high value for day %d: ", i + 1);

scanf("%d", &high);

printf("\n");

printf("Enter the low value for day %d: ", i + 1);

scanf("%d", &low);

printf("\n");

}

totalhigh = high + totalhigh;

totallow = low + totallow;

if (high > highest)

{

highest = high;

highd = i + 1;

}

if (low < lowest)

{

lowest = low;

lowd = i + 1;

}

}

average = (double)(totalhigh + totallow) / 6;

printf("The average (mean) temperature was: %.2lf\n", average);

printf("The lowest temperature was%3d on day %d\n", lowd, lowest);

printf("The highest temperature was%3d on day %d\n", highd, highest);

return 0;

}

1 Answer

0 votes
answered Sep 30, 2018 by Amey
You need check your loop condition. The loop should be like:

for(i=0;i<=3;i++)

{

//code

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...