Ask Question
8 June, 15:45

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.

+3
Answers (1)
  1. 8 June, 16:32
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers