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

How did the nature of labor shape early colonial society in North America
Why did some college leaders believe that the freed slaves should learn job skills?
Why is the title of the story important? What does it mean
Why might algebra tiles not be a good tool to use to factor x2 + 18x + 80? Explain.
Which mathematical statement represents “17 more than a number is 26”?
Which word best completes this sentence? Once a person's blood alcohol content increases to 0.08% he is legally ________________ and is not permitted to drive
If....1=5 , 2=10, 3=30, then 4=?
A new truck that sells for 29,000 depreciates 12% each year. What is the decay factor b?
The two most reactive families of elements are the halogens and the alkali metals. how do they differ in their reactivities?
During the industrial Revolution locating factories near concentrations of natural resources and transportation routes most directly promoted