TrivialRen1465 TrivialRen1465
  • 20-01-2020
  • Computers and Technology
contestada

What is the output of the following function if the array nums contains the values 1 2 3 4 5 int backwards(int nums[]) { for (x = 4; x >=0; x--) { cout << nums[x] << " "; } return 0; }

Respuesta :

ijeggs
ijeggs ijeggs
  • 21-01-2020

Answer:

The output of the program is:

5 4 3 2 1

Explanation:

The output of the array will be the reverse of the elements in the array since the initial array was 1 2 3 4 5. The function backwards uses a for statement to accomplish this. Starting at index 4 which is the last element, since there are five elements (indexes from 0-4), the for statement prints out the xth element, decreases x by 1 and continues until the condition is no longer true.

Answer Link

Otras preguntas

what is f(6) for the quadratic function​
Dennis takes care of private swimming pools. He charges $50 to travel to a home and then $35 per hour. The equation t = 50 + 35h models the total charge t for h
PLEASE HELP!! IM CONFUSED AND NEED TO GET MY LATE WORK IN ASAP!
Who was convicted of giving U.S. atomic secrets to the Soviet Union? (1 point)
Can someone solve these 2 problems?​
15 Pts! Which words are the antecedent of the underlined pronoun? Harvey and Justin took forever to finish assembling (their) tree house. (The word ("Their") i
How is almond milk made??
Which reform movement is incorrectly matched with woman who supported it? 1.Mental health reform-Dorothea Dix 2.Woman's education-Elizabeth Blackwell 3.Abolitio
True or false Not all volcanoes form along plate boundaries
In the derivation of the formula for the volume of a cone, the volume of the cone is calculated to be times the volume of the pyramid that it fits inside. Which