Runtime error (SIGSEGV). Please check my code.

#include<stdio.h>
int main()
{
int n, h[20],i,d=0,k,j;
printf("\nNo of Students: “);
scanf(”%d",&n);
printf("\nHeight of students: “);
for (i=0; i<n; i++)
scanf(”%d",&h[i]);
i=0;
for (j=0; j<n; j++)
{
if (h[i]<h[i+1])
{

  i++;
  
  }
else
  {
  ++d;
    for (k=0; k<n; k++)
	  h[k]=h[k+1];
  }

}

printf("\noutput is : %d",d);
return 0;
}

It seems you are allocating less memory,but the question requires more.i.e size of the array.It would have been easy to tell if you would have shared the link of the problem.Because usually run time error comes when you are trying to access those locations which you haven’t allocated.
Increase the size of the array,or make it

h[n];

Hope this helps.
Happy Coding!!

You are allocating less memory as said above , and you are trying to access the nth index at the end of both of your loops even if you get memory fixed you will get wrong answer so run your loop till n-1.

Since you have not specified the question, it’s hard to tell exactly. But one of the problems might be h[20]. You might need more than 20.

You also have bugs here

for (k=0; k<n; k++)
  h[k]=h[k+1];
         ^
        at k=19, h[k+1] will try to access h[20] which is out of bounds.

Also, if you’re trying to submit an answer to one of the questions on codechef, then you don’t need output like " No of Students:" and all. They will just give you Wrong Answers. You can read this
It has been stated there that

Submitted solutions are automatically
compiled and run under Linux test
system. You must keep strictly the
input output specification. In
particular your program must not
printout any additional messages like
‘input the number please’, which are
not specified in the problem
formulation.

Can you please specify which question this code belongs to.