Thread: Need help with explaining how to set up a function using arrays

  1. #1
    Registered User
    Join Date
    Apr 2013

    Need help with explaining how to set up a function using arrays

    Hello, I'm wondering if anyone can run me through how to make the functions for b, c, d. if possible running through on how to would be more beneficial than just giving me the answer. Any explanation is appreciated.

    Global warming.
    As part of a global warming analysis, a research facility tracks outdoor temperatures at the North Pole
    once a day, at noon, for a year. At the end of each month, these temperatures are entered into the
    computer and processed. The operator will enter 28, 29, 30, or 31 data items, depending on the month.
    You may use 500 as a sentinel value after the last temperature, since that is lower than absolute 0.
    Your main program should call the read_temps(), hot_days(), and print_temps() functions described

    (b) Write a function, read_temps(), that has one parameter, an array called temps, in which to store
    the temperatures. Read the real data values for one month and store them into the slots of an array.
    Return the actual number of temperatures read as the result of the function.
    (c) Write a function, hot_days(), that has two parameters: the number of temperatures for the current
    month and an array in which the temperatures are stored. Search through the temperature array
    and count all the days on which the noon temperature exceeds 32F. Return this count.
    (d) Write a function, print_temps(), with the same two parameters plus the count of hot days. Print
    a neat table of temperatures. At the same time, calculate the average temperature for the month
    and print it at the end of the table, followed by the number of hot days.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Presumably, you're at least capable of doing

    printf("Enter a temperature\n");
    scanf("%f", &temperature);

    If you are, then I suggest your first attempt at "b" would be an array and for loop in main.

    After that, you read this -> A development process
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-04-2013, 05:35 PM
  2. Need help explaining
    By witt in forum C++ Programming
    Replies: 1
    Last Post: 10-11-2011, 03:06 PM
  3. Help: Explaining Code
    By Student1 in forum C++ Programming
    Replies: 6
    Last Post: 02-08-2008, 03:31 AM
  4. need help explaining this code
    By lastresort in forum C++ Programming
    Replies: 4
    Last Post: 02-02-2005, 04:46 PM
  5. I need help explaining something...
    By deathstryke in forum A Brief History of
    Replies: 1
    Last Post: 01-08-2003, 12:02 PM