In: Computer Science
C++
Write a function that accepts an array of doubles and the array's size as arguments. The function should display the contents of the array to the screen.
The Program Code Is :
///Cpp Program
///function that accepts an array of doubles and the array's size
as arguments.
///The function should display the contents of the array to the
screen.
#include<iostream>
using namespace std;
void function_double(double *arr,int n)/// Function
Definition
{ /// With Double
int i;
cout<<"\n\nThe array elements are in Function is :
\n"<<endl;
for(i = 0;i < n; i++)
{
cout<<arr[i]<<"\t";///This will display the array
elements
}
cout<<endl;
}
int main()
{
int n,i;
cout<<"Enter the size of array"<<endl;
cin>>n;
double *p=new double[n];
cout<<"Enter the array elements : "<<endl;
for(i=0;i<n;i++)
{
cin>>*(p+i);///This will read the elements to array
}
function_double(p,n);///Function Calling
return 0;
}