I was trying to a simple program of passing the inputted numbers of the arrays and displaying it using the function but it shows random value. What am I doing wrong?
#include<stdio.h>
#define size 5
void display();
int main()
{
int arr[size];
int i;
for(i = 0; i < size; i++){
printf("Input a number at index %d: ", i);
scanf("%d", &arr[i]);
}
display();
}
void display(){
int i;
int arr[size];
for(i = 0; i < 5; i++)
printf("Element[%d] = %d\n", i, arr[i]);
}