If I want to give 10 elements, I scan how_many
as 10.
But as soon as I enter the third value, the program crashes and returns some long negative value. I don't know where is the problem.
int main()
{
int how_many,k;
int data[how_many];
printf("Enter the number of values to be sorted..: ");
scanf("%d",&how_many);
printf("Enter the values one by one..:\n");
for (k=0;k<how_many;k++)
{
scanf("%d",&data[k]);
printf("data[%d]=%d\n",k,data[k]);
}
return 0;
}