In desire need of C help

This is a discussion on In desire need of C help within the C Programming forums, part of the General Programming Boards category; So I am seriously stuck with a C program that I have to write for class. Unfortunaltely I just heard ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    5

    In desire need of C help

    So I am seriously stuck with a C program that I have to write for class. Unfortunaltely I just heard about this site and its extremely last minute, its due tomorrow. I tried to get help otherwise but that was not successful. This program is dealing with loops. It needs to count and print the number of hot days (high temperature 85 or higher), the number of pleasant days (high temperature 60-84), and the number of cold days (high temperatures less than 60). It also needs to print min, max, and avg. Also, we are reading the info from an input file. It compiles fine, and I have used the examples that have been given to me as well as my book. As i said, i know its last minute but any help would be greatly appreciated.



    #include <stdio.h>

    int main (void)
    {
    int counter=0, counterhot=0, counterpleasant=0,
    countercold=0, total = 0, num=0, temp=0;
    int min, max;
    float average=0;

    scanf("%d",&min);
    total += min;
    counter++;

    while((scanf("%d",&num)) == 1){
    total =+ num;
    counter++;
    if (num < min)
    min = num;
    }

    scanf("%d", &max);
    total += max;
    counter++;

    while((scanf("%d",&num)) == 1){
    total =+ num;
    counter++;
    if (num > max)
    max = num;

    if (temp >84)
    counterhot++;
    printf("The number of hot days = %d\n", counterhot);
    if (temp < 85 && temp > 59)
    counterpleasant++;
    printf("The number of pleasant days =%d\n",
    counterpleasant);
    if (temp < 60)
    countercold++;
    printf("The number of cold days = %d\n", countercold);

    average = total/counter;

    printf("%d", temp);
    printf("You entered %d temperatures\n", counter);
    printf("The total = %d\n", total);
    printf("The average temperature = %f\n", average);
    printf("Maximum = %d\n", max);
    printf("Minimum = %d\n", min);
    return 0;

    }

  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    5
    Sorry I didnt post the code in the proper format...guess I should have read everything first...

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    My last minute help is: "You're screwed."
    Code:
    if number in range of good
        good++
    if number in range of bad 
       bad++
    if number in range of so-so
        soso++
    if this temperature greater than great
        great = this temperature
    if this temperature lower than low
        low = this temperature
    suml += this temperature
    totalcount++
    There's the basic idea. Get your file writing done and that's all there is to it.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. completed a program; desire input
    By spirited in forum C++ Programming
    Replies: 2
    Last Post: 05-25-2003, 08:50 AM
  2. Desire & Fear: Two Basics of Human..
    By zahid in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 11-16-2002, 10:11 PM
  3. What is your most secret desire?
    By Brian in forum A Brief History of Cprogramming.com
    Replies: 35
    Last Post: 04-22-2002, 05:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21