this is the Qustion:
Write C++ program that contains two functions: main and a function named "reverse". You should initialize an array of floating point values in the main and print it then send it to the function “reverse” that takes as its arguments the following:
(1) an array of floating point values;
(2) 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. Thus, for example, if the array that's passed to the function looks like this:
0 1 2 3 4
5.8 | 2.6 | 9.0 | 3.4 | 7.1
then when the function returns, the array will have been modified so that it looks like this:
0 1 2 3 4
7.1 | 3.4 | 9.0 | 2.6 | 5.8
The function should not return any value. Finally you should print the reversed array in the main.
and this is my code there is somrthing wrong with the output but i didn't know where it is, really need help.
#include<iostream>
using namespace std;
float reverse(float a[]);
int main()
{
int n;
float x[5];
cout<<"please enter the range of array: "<<endl;
for(int i=0;i<5;i++)
{
cout<<"please enter a float number :"<<endl;
cin>>x[i];
}
float reverse(x[5]);
}
float reverse(float a[5])
{
float y[5]={0.0};
for( int i=0;i<5;i++)
{
y[i]=a[i];
}
for(int i=4;i<=0;i--)
cout<<y[i];
cout<<"the number of the numbers is"<<5;
return 0;
#include<iostream>
usingnamespace std;
float reverse(float a[]);
int main()
{
float x[5];
cout<<"please enter the range of array: "<<endl;
for(int i=0;i<5;i++)
{
cout<<"please enter a float number :"<<endl;
cin>>x[i];
}
reverse(x);
}
float reverse(float a[5])
{
float y[5]={0.0};
int j=5;
for( int i=0;i<5;i++)
{
y[i]=a[j];
j--;
}
for(int i=0;i<5;i++)
cout<<y[i];
cout<<"the number of the numbers is"<<5;
return 0;
}
...the function “reverse” that takes as its arguments the following:
(1) an array of floating point values;
(2) an integer that tells how many floating point values are in the array.
...The function should not return any value....
void reverse(float data_set[], int data_count);
Edit: also note that reverse() should not print anything, only reverse the array. You need to read your requirements more accurately.