Ask Question
22 November, 17:35

Write a loop to print all elements in hourly_temperature. Separate elements with a - > surrounded by spaces. Sample output for the given program with input: '90 92 94 95' 90 - > 92 - > 94 - > 95 Note: 95 is followed by a space, then a newline.

+1
Answers (1)
  1. 22 November, 17:53
    0
    The program to this question can be described as follows:

    Program:

    #include / /defining header file

    using namespace std;

    int main () / /defining main method

    {

    int hourly_temperature[] = {90,92,94,95}; / /defining integer array

    int len = sizeof (hourly_temperature) / sizeof (hourly_temperature[0]); / /calculate length of array

    for (int i=0; i
    {

    cout<
    }

    cout<
    return 0;

    }

    Output:

    90->92->94->95

    Explanation:

    In the given code an integer array "hourly_temperature" is declared, which holds some value, that is "90,92,94,95", in the next step, an integer variable "len" variable is declared, that holds array size.

    Then a for loop is declare that uses the "i" variable, which starts from 0 and ends when the "i" value is less than "len-1". Inside the loop array values are printed with the "->" sign, and outside the loop, the last variable value is printed.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a loop to print all elements in hourly_temperature. Separate elements with a - > surrounded by spaces. Sample output for the given ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers