Thread: Temperature Analyzer Help

  1. #1
    Registered User
    Join Date
    Sep 2018

    Temperature Analyzer Help

    Hi, I'm not understanding fully how to go about this, Ive made an analyzer for calculating the mean for temps and i need to have it display the highest temp and on the day that it occurred along with the low temp. If any of you can show and explain it to me it will be greatly appreciated. Thanks. My current code is below, using C.

    int main(void)
        printf("\n---=== IPC Temperature Analyzer ===---\n");
        int low, high, i = 1;
        double totalhigh = 0, totallow = 0;
        do {
            printf("Enter the high value for day %d: ", i);
            scanf("%d", &high);
            printf("Enter the low value for day %d: ", i);
            scanf("%d", &low);
            if (high > low && high <= 40 && low >= -40) {
                totalhigh += high;
                totallow += low;
            else {
                printf("Incorrect values, temperatures must be in the range -40 to 40, high must be greater than low.\n\n");
        } while (i < 5);
        double avgtemp = (totalhigh + totallow) / (NUMS * 2);
        printf("The average (mean) temperature was: %0.2lf\n", avgtemp);
        return 0;

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Change your 'i' variable to be a more meaningful name such as 'day'.

    Then you want a couple more variables such as
    int highestTemp;
    int dayOfHighestTemp;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2018
    Thanks, This helped me figure it out

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Temperature analyzer C program help
    By BlackUmbreon in forum C Programming
    Replies: 12
    Last Post: 02-17-2017, 04:17 PM
  2. My numeric analyzer
    By siavoshkc in forum C++ Programming
    Replies: 22
    Last Post: 07-15-2007, 09:54 AM
  3. Protocol Analyzer
    By NewGuy100 in forum Networking/Device Communication
    Replies: 5
    Last Post: 09-12-2005, 03:31 PM
  4. packet analyzer in c
    By althagafi in forum C Programming
    Replies: 1
    Last Post: 07-26-2004, 11:46 PM
  5. stat analyzer available on the net?
    By iain in forum A Brief History of
    Replies: 0
    Last Post: 01-21-2002, 08:12 AM

Tags for this Thread