C What is the output of the following function if the array
C++
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;
}
Solution
Answer
Walking through the given code we get:
num[] = {1, 2, 3 , 4, 5}
loop is going from 4 to 0, i.e. decreasing loop
content of array is getting printed from 4th index to 0th index
so the output will be
5 4 3 2 1
![C++ 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 & C++ 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 &](/WebImages/41/c-what-is-the-output-of-the-following-function-if-the-array-1127177-1761601316-0.webp)