Write a program that first reads at most 30 numbers of type
Write a program that first reads at most 30 numbers of type double from the user (the user will type character quit when finished), and stores these values in an array in the same order that they were entered by the user. Your program should then call the function reverse_array with this array as an argument, and finally displays the new contents of the array to the screen, 5 values per line. Sample Input/Output: (the user’s input is shown in bold) Please enter at most 30 numbers; type quit when finished. 1396 470 -9 -1 9180 -5011 0 2-275 13 216 15 -7 quit The array in reverse order (5 values per line) is : -7 15 216 13 -275 2 0 -5011 9180 -1 -9 470 1396
Solution
#include<iostream>
using namespace std;
int main()
{
double arr[30];
double a;
cout<<\"\ enter array values \";
cin>>a;
arr[0]=a;
cout<<\"\ do you want to enter another value(y/n):\";
char ch;
cin>>ch;
int i=1;
while(ch!=\'n\')
{
cout<<\"\ enter value :\";
cin>>a[i];
cout<<\"\ do you want to enter another value(y/n):\";
cin>>ch;
i++;
}
reverse_array(arr,i);
return 0;
}
void reverse_array(double a[],int i)
{
for(int j=i;j>=0;j--)
{
cout<<a[j];
}
}

