Write a function named "reverse" in C++, which takes the arguments as follows:
·
an array of floating point values.
·
an integer that tells how many floating
point values are in the array.
The
function must reverse the order of the values in the array. The function should
not return any value. Example, if the array contain as follows,
1 2 3 4 5
5.9 |
2.5 |
8.0 |
3.2 |
7.3 |
After
the execution of the function returns the array given below.
1 2 3 4 5
7.3 |
3.2 |
8.0 |
2.5 |
5.9 |
#include<iostream>
using namespace std;
float reverse(float rev[5]);
int main()
{
float
array[5]={5.9,2.5,8.0,3.2,7.3};
reverse(array);
}
float reverse(float rev[5]){
cout<<"reverse
array is "<<endl;
for(int
i=4; i>=0; i--)
{
cout<<rev[i]<<"\t";
}
}
0 Comments