You have to declare or define functons before using.
Add declaration before using:
#include <stdio.h>
/* declarations of functions */
int getArray(int arr[10],int i);
int displayArray(int arr[10], int i);
int main(void)
{
int arr[10],i;
getArray(arr,i);
displayArray(arr,i);
}
int getArray(int arr[10],int i)
{
printf("Enter 5 numbers: \n");
for (i=0; i<5; i++)
{
scanf("%d",&arr[i]);
}
return arr;
}
int displayArray(int arr[10], int i)
{
for (i=0; i<5; i++)
{
printf("%d ",arr[i]);
}
return 0;
}
Move definitions of functions before using:
#include <stdio.h>
int getArray(int arr[10],int i)
{
printf("Enter 5 numbers: \n");
for (i=0; i<5; i++)
{
scanf("%d",&arr[i]);
}
return arr;
}
int displayArray(int arr[10], int i)
{
for (i=0; i<5; i++)
{
printf("%d ",arr[i]);
}
return 0;
}
int main(void)
{
int arr[10],i;
getArray(arr,i);
displayArray(arr,i);
}
Also note that you should use standard int main(void)
in hosted environment instead of void main()
, which is illegal in C89 and implementation-defined in C99 or later, unless you have some special reason to use non-standard signature.