How to fix array length in the following code?

0

In the following source code the max array length is 500000. It ran without problem but when I set the length to 600000, there are no output. Can anyone explain it why is this happening?

#include<stdio.h>
#include<math.h>
#include<time.h>
void insertion_sort(int [], int );
int main()
{
    int a[600000],i,n;
    clock_t s,e;
    double d;
    printf("Enter the amount of data: ");
    scanf("%d",&n);
    for(i = 0;i < n; i++)
    {
        a[i]=rand();
    }
    s = clock();
    insertion_sort(a,n);
    e = clock();
    d = ((double)(e-s))/CLOCKS_PER_SEC;
    printf("Execution time: %f",d);
}
void insertion_sort(int a[], int n)
{
    int i,j,key;
    for(j = 1;j < n; j++)
    {
        key = a[j];
        i = j-1;
        while(i>=0 && a[i]>key)
        {
            a[i+1] = a[i];
            i--;
        }
        a[i+1] = key;
    }
}

There should be some input procedure but output returned as follows:

Process returned -1073741571 (0xC00000FD) execution time : 2.491 s Press any key to continue.

c
asked on Stack Overflow Feb 12, 2019 by Asequr Rahman

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0