Question: 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,
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.
CODE:
#include
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 */ for (i = 0; i < NUM_VALS; ++i) { if(i==0) cout << hourlyTemp[i] << " " << endl; else cout << hourlyTemp[NUM_VALS - 1] << ", " << endl; }
need help its not working
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
