I cannot find my era as to why the program wont exit. No matter the number i input it still continue to run. If someone cant point out my era it would be highly appreciate..

#include <stdio.h>
#include <conio.h>
#define FROZEN -99
#define BOILING 212
int main(void)
{
    int temp, hot_days, cold_days, pleasant_days, sum, avg, count;
    count = 0;
    sum = 0;
    hot_days = 0;
    cold_days = 0;
    pleasant_days = 0;
    
    
    printf("Please Enter The daily High Temperature(enter -99 or 212 to exit):\n");
    do {
        scanf("%d", &temp);
        }
          while((temp != -99) || (temp != 212)); 
    if (temp<60){
                 cold_days++;
                 count++;
                 sum = sum +temp;
                 }
    else if(temp>84){
                 hot_days++;
                 count++;
                 sum = sum + temp;
                 }
    else if((temp >= 60) && (temp <=84)){
                  pleasant_days++;
                  count++;
                  sum = sum + temp;
                 }
    
    avg = sum/count;
    printf("\nThere are %d cold days\n", cold_days);
    printf("There are %d hot days\n", hot_days);
    printf("There are %d pleasant days\n", pleasant_days); 
    printf("The Average temperature from daily highs are: %d\n ", avg);                   
    
    getch();              
 return(0);

nevamind I figured it out while statement goes at the end of the if else statements thanks for the quick response

why don't u better use a CHAR as a centinel? like this:

char ans;
   do{
      (program)
      printf("Do you wish to enter another temperature?");
      scanf("%c",&ans);
      }while ((ans=='y')||(ans=='Y'));

why don't u better use a CHAR as a centinel? like this:

char ans;
   do{
      (program)
      printf("Do you wish to enter another temperature?");
      scanf("%c",&ans);
      }while ((ans=='y')||(ans=='Y'));

Hopefully, because of this :icon_wink:

Hopefully, because of this :icon_wink:

The thing is, i always take care to make my programming "stupid proof", and this way, if the user makes any mistake at entering his/her answer, such as entering "yes", it will not fill up the buffer and screw up the program... maybe if when using the

if (getchar()=='y')

you flush the buffer before the next input... ;)

This question has already been answered. Start a new discussion instead.