C program not displaying the output getting error process returned -1073741819 (0xC0000005)

-1

This is my code. Its one of the questions from codechef.

#include<stdio.h>
int main()
{
    int N,K,posi=0,posf=2,min=0,minloc,prod=1;
    int stno[10],num[10];
    scanf("%d",&N);
    scanf("%d",&K);
    for(int i=0;i<N;i++)
    {
        printf("%d. ", (i+1));
        scanf("%d", &stno[i]);
    }
    min = stno[1];
    prod = prod*stno[0];
    printf("%d %d",min,prod);
    while(posf!=N)
    {
        for(int j=1;j<=K;j++)
        {
            if((posi+K)>=(N-1))
            {
                min = stno[N-1];
                posf=N;
            }
            if((posi + j)<N)
            {
                if(min>stno[posi+j])
                {
                    min=stno[posi+j];
                    minloc=posi + j;
                }
            }
        }
        prod = prod*min;
        min = stno[minloc+1];
        posi = minloc;
    }
    printf("%d",prod);
    return 0;
}

I am getting the above error which is related to memory issue What are tips and techniques to save memory?

c
stdio

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0