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
Convert this C++ program exactly as you see it into x86 assembly language: // Use the...
Convert this C++ program exactly as you see it into x86 assembly language: // Use the Irvine library for the print function #include <iostream> // The string that needs to be printed char word[] = "Golf\0"; // Pointer to a specific character in the string char * character = word; //NOTE: This main() function is not portable outside of Visual Studio void main() { // Set up a LOOP - See the while loop's conditional expression below int ecx =...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's...
Consider the C program (twoupdate) to demonstrate race condition. In this assignment, we will implement Peterson's algorithm to ensure mutual exclusion in the respective critical sections of the two processes, and thereby eliminate the race condition. In order to implement Peterson's Algorithm, the two processes should share a boolean array calledflagwith two components and an integer variable called turn, all initialized suitably. We will create and access these shared variables using UNIX system calls relating to shared memory – shmget,...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing...
I'm currently stuck on Level 3 for the following assignment. When passing my program through testing associated with the assignment it is failing one part of testing.   Below is the test that fails: Failed test 4: differences in output arguments: -c input data: a b c -c expected stdout: b observed stdout: a b expected stderr: observed stderr: ./test: invalid option -- 'c' Unsure where I have gone wrong. MUST BE WRITTEN IN C++ Task Level 1: Basic operation Complete...
I did already posted this question before, I did get the answer but i am not...
I did already posted this question before, I did get the answer but i am not satisfied with the answer i did the code as a solution not the description as my solution, so i am reposting this question again. Please send me the code as my solution not the description In this project, build a simple Unix shell. The shell is the heart of the command-line interface, and thus is central to the Unix/C programming environment. Mastering use of...