Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Collecting, Storing and Organizing Data :)
Index -> Programming, C -> C Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
athanaba




PostPosted: Tue Feb 28, 2012 11:56 am   Post subject: Collecting, Storing and Organizing Data :)

Hey guys !

I have an assignment which asks me to allow the user to input daily temperatures, and then count and display the number of high, medium and low temperatures.
I know that I'd have to use a loop to ask the user to continually put in temperatures, and if statements for the different categories , but am lost beyond that !
Any help would be appreciated !

Thank youuu Very Happy

Ash
Sponsor
Sponsor
Sponsor
sponsor
bl0ckeduser




PostPosted: Sun Mar 04, 2012 10:22 am   Post subject: Re: Collecting, Storing and Organizing Data :)

athanaba @ Tue Feb 28, 2012 11:56 am wrote:
Hey guys !

I have an assignment which asks me to allow the user to input daily temperatures, and then count and display the number of high, medium and low temperatures.
I know that I'd have to use a loop to ask the user to continually put in temperatures, and if statements for the different categories , but am lost beyond that !
Any help would be appreciated !

Thank youuu Very Happy

Ash


This version compiles high/mid/low temperatures as they are read in:

code:
#include <stdio.h>
#include <stdlib.h>

main()
{
        float temp;
        int low = 0, mid = 0, high = 0;

        while(1) {
                scanf("%f", &temp);

                /* break if we reached end of input */
                if(feof(stdin)) break;

                if(temp <= 0.0f)        ++low;
                else if(temp <= 15.0f)  ++mid;
                else if(temp <= 30.0f)  ++high;
        }

        printf("low:%d, mid:%d, high:%d\n", low, mid, high);
        return 0;
}
S_Grimm




PostPosted: Mon Mar 05, 2012 8:53 am   Post subject: Re: Collecting, Storing and Organizing Data :)

bl0ckeduser @ Sun Mar 04, 2012 10:22 am wrote:


This version compiles high/mid/low temperatures as they are read in:


Just a little bit of information, around these parts handing people completed code is frowned upon. You should instead just give advice and ask the Original Poster (here forth referred to as the OP) to post his / her code. Read the OP's code and then offer suggestions based on what they are doing wrong.

On the other side, athanaba, can you post what you have so far? We are unable to offer suggestions without knowing what you currently have! Thank you!
Display posts from previous:   
   Index -> Programming, C -> C Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: