Question

Create a C Program called Summer_Heat that meets the following criteria: Lines 1,2: Identifies the name...

Create a C Program called Summer_Heat that meets the following criteria:

  • Lines 1,2: Identifies the name of Program that the Programmer
  • Lines 4,5: Includes the header files to allow input and output and use the system commands
  • Line 7: Includes Declarations comment
  • Line 8: Declares counter as an integer with an initial value of 0
  • Line 9: Initializes a double array called temperature using a single statement and the following 10 values
    78.6 82.1 79.5 75.0 75.4 71.8 73.3 69.5 74.1 75.7
  • Line 11: Contains Main Program comment
  • Line 12: Begins main program code, including system(“pause”) and return 0 statements
  • Line 14: In main block, Displays on screen “The Daily Temperatures for the last 10 Days Were: “ and advances to next line
  • Line 15: Begins a while loop that tests if counter < 10
  • Line 17: Within while loop prints temperature values 1 line at a time with 1 decimal place
  • Line 18: Increments counter
  • Line 19: Closes while loop
  • Lines 20, 21: Contains system(“pause”); and return 0;

Homework Answers

Answer #1

Source code:

// Program name: Summer_Heat
// Programmer name

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

//Declarations
int counter=0;
double temperature[10]={78.6,82.1,79.5,75.0,75.4,71.8,73.3,69.5,74.1,75.7};

//Main Program
int main( )
{
   printf("The Daily Temperatures for the last 10 Days Were:\n");
   while(counter<10)
   {
       printf("%.1f\n",temperature[counter]);
       counter++;
   }
   system("pause");
   return 0;
}

code screenshot:

output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions