#include<math.h>
#include<stdio.h>
#include<stdlib.h>
float array(float a[],int n);
int main() {
int k=5;
float a[k+1];
array(a[k+1],k);
}
float array(float a[],int n )// n = size of array
{
printf("enter elements in order of increasing:\n");
for(int i=0;i<n;i++) {
printf("array[%d]:",i);
scanf("%f",&a[i]);
}
return a;
}
I want to build a program for using a function to give an array with increasing float numbers but it has a bug and the compiler shows these errors:
[Error] cannot convert 'float*' to 'float' in return9
[Error] cannot convert 'float' to 'float*' for argument '1' to 'float array(float*, int)'
a
is of type float*
, the return type is float
. You either need to return one float, or convert the return type to a pointer.