1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
balandron [24]
3 years ago
14

Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp

= {90, 92, 94, 95}, print: 90, 92, 94, 95 Your code's output should end with the last element, without a subsequent comma, space, or newline. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include using namespace std; int main() { const int NUM_VALS = 4; int hourlyTemp[NUM_VALS]; int i; for (i = 0; i < NUM_VALS; ++i) { cin >> hourlyTemp[i]; } /* Your solution goes here */ cout << endl; return 0; } 1 test passed All tests passed Run
Computers and Technology
1 answer:
MA_775_DIABLO [31]3 years ago
8 0

Answer:

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.    const int NUM_VALS = 4;
  6.    int hourlyTemp[NUM_VALS];
  7.    int i;
  8.    
  9.    for (i = 0; i < NUM_VALS; ++i)
  10.    {
  11.        cin >> hourlyTemp[i];
  12.        
  13.    }
  14.    
  15.    /* Your solution goes here */
  16.    for(i = 0; i < NUM_VALS; ++i){
  17.        
  18.        if(i < NUM_VALS -1){
  19.            cout<<hourlyTemp[i]<<",";
  20.        }
  21.        else{
  22.            cout<<hourlyTemp[i];
  23.        }
  24.    }
  25.    cout << endl;
  26.    return 0;
  27. }

Explanation:

The solution code is given from Line 18 - 26. To print the element from array one after another, we create a for loop to traverse through every element in the array (Line 18). Create an if condition to check if the current index i is not the last index, print the element followed with a comma (Line 20 -22). Otherwise print only the element (Line 23 - 25).

You might be interested in
Which programming languages is best for game development? ​
kvasek [131]

Answer:

JavaScript. .

HTML 5.

SQL.

Python. .

Explanation:

hold it helps◕‿◕

3 0
3 years ago
What is application launchers functions​
andrey2020 [161]
An app launcher replaces the stock user interface for organizing the home screen and app icons predominantly in the Android world; however, they are also available for jailbroken iPhones (see iPhone jailbreaking and Cydia). See Launchpad.
5 0
4 years ago
5. The problem domain refers to the
solong [7]

Answer:

The problem domain refers to the support options.

6 0
3 years ago
Addition and subtraction are considered to be ____ operations performed by a computer.
Natali5045456 [20]

Answer:

Mathematical operations

4 0
4 years ago
Trace the code below to find the two errors.
nasty-shy [4]

Answer:subtotal =.08

Explanation:

8 0
3 years ago
Other questions:
  • A______ is a picture icon that is a direct link to a file or folder
    13·1 answer
  • What does AAC stand for?
    11·2 answers
  • Assume that the array monthSales of integers has already been declared and that its elements contain sales data for the 12 month
    13·1 answer
  • which software is used to mimic intricate hand drawings into digital paintings? _____ is used to replicate hand drawings into di
    7·1 answer
  • Effective presentations vary the color scheme on each slide.<br><br> True<br> False
    5·2 answers
  • In information systems, _____ is information from a system that is used to make changes to input or processing activities.
    6·1 answer
  • The data-linking feature that allows Internet users to skip directly from a highlighted word to a related file in another comput
    12·2 answers
  • What does RFID use for wireless communication?<br> Infrared<br> IoT<br> Smart chip<br> Tag
    14·1 answer
  • ____ returns the maximum number of elements that can be inserted into the vector container vecCont without reallocation.
    9·1 answer
  • How to use access?<br> like working in access and bringing tables and stuff
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!