I want to create two functions, one that takes array values and lenngth
and the other displays array values and length
Here is my code, it gives me segmentation fault
#include <iostream>
#include <iomanip>
using namespace std;
void input_array(float a[], int &n)
{
int j;
for (j=0; j<n; j++)
{
cin>>a[j];
}
}
void print_array(float a[], int n )
{
int i;
for (i=0; i<n; i++)
{
cout<<a[i]<<endl;
}
}
main()
{
int n;
float a[n];
//int n;
cout<<"Input the array size you want"<<endl;
cin>>n;
cout<<"enter the array elements"<<endl;
input_array(a, n);
print_array(a, n);
}