in

WHY I GET SEGEMENT FAULT ERROR IN C LANGUAGE WHEN I USE 1-D ARRAY


#include <stdio.h>

int main()


{
   
//Initialize array
int n;
int x[n],y[n];
printf("enter the size of array:");
scanf("%d",&n);
if(n>0)

{
    for (int i = 0; i < n; i++)
{

    printf("enter elements : n");
    scanf("%d ",&x[i]);
}

    
}

printf("Array in reverse order: n");
//Loop through the array in reverse order
for (int i = n-1,j=0; i >= 0; i--,j++)
{
    y[j]=x[i];
    printf("%d ", y[j]);
}
return 0;

}

Above program, I have created a array which size can be decided by user
And also user can put elements in it
So after that I want to reverse this array and want to store in another array
But got this error again and again I have tried codeblock with gcc compiler
But here I got different problem, my program get wired
So anyone can help me to understand this problem
I am a beginner in coding



Source: https://stackoverflow.com/questions/70718971/why-i-get-segement-fault-error-in-c-language-when-i-use-1-d-array

Movie Ticket Reservation App made with Tkinter

Initializing VB.NET DataGridView to have all Combo Boxes; Button to populate from Array