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

I don't know how to solve it
Find the slope of a line parallel to the graph of 1/2y=x+6
What is the total number of valence electrons in a sulfide in th ground state?
Which value of x would make TV || QS ? A. 3 B. 8 C. 10 D. 11
how do you explain to a 4 yr old, how ice floats?
Although expensive, platinum is used as a catalyst to break down harmful gasses in car exhaust into less harmful gasses. Which statement best describes platinum
GOVERNMENT: define the "nolan model" in your own words, please
Which of these sources of energy have not acquired energy from sun?? A. Petroleum B. Wind C. Coal
Most of the milk _____ gone bad. six gallons of milk _______ still in the refrigerator
What was an outcome of the North Atlantic Treaty? A. The United States extended its policy on isolationism. B. The Soviet Union blockaded Berlin. C. North Korea