Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

variable name also should be exactly same. thank you in advance. Exercise P7.7.

ID: 3728873 • Letter: V

Question

variable name also should be exactly same.

thank you in advance.

Exercise P7.7. Write a function that reverses the values of an array of floating-point data: void reverse .double at, int a size) In the function, use two pointer variables, and not integer indexes, to traverse the array elements. ·Write the function reverse (double a[], int a.size ()) described in Problem P7.7. Write a program that reads in a list of numbers contiguously in an array double x[100]. The user may enter no more than 100 numbers (but less is ok). Let x size be the number of numbers entered by the user. Note x [100] serves as a storage and x size indicates the

Explanation / Answer

Code of the avobe program is given below:


#include <iostream>
using namespace std;
void reverse(double a[],int a_size ){
cout<<"Reversed list: ";
for(int i=a_size-1;i>=0;i--) //for loop to reverse the array
{
cout<<a[i];
if(i>0){
cout<<",";
}
}
cout<<endl;
}
int main() {
double x[100];
int size,i=0; //size and counter
char sc; // flag to continue
do
{
size=0;
i=0;
cout<<"Enter the no elements of the list"<<endl;
cin>>size;
cout<<"Enter a list of numbers:";
while (i<size) //loop to enter the list
{
cin>>x[i];
i++;
}
reverse(x,size); // calling the function
cout<<"Continue (y/n)?";
cin>>sc;
}while(sc=='y'||sc=='Y');
}
Output:

Enter the no elements of the list
4
Enter a list of numbers:1 2 3 4
Reversed list: 4,3,2,1
Continue (y/n)?yEnter the no elements of the list

4
Enter a list of numbers:2 5 4 10
Reversed list: 10,4,5,2
Continue (y/n)?n

refer to the comments inline.

note: For any info drop a comment