vendredi 1 novembre 2019

which part is causing "SIGSEGV" error and how to fix it?

i am facing a runtime error "SIGSEGV" in this code , i searched about it and what i got is ,this error is caused due to segmentation fault , i am not able to find segmentation fault in this .i want to know how to fix this error .

#include <iostream>

using namespace std;

int counti(int A[],int N)
{
    int d=0,i;

        for(i=0;i<N;++i)
        {
            if(A[i]==A[N-1])
            {
                d++;
            }
        }

        return d;
}

int main()
{
    int T;
    cout<<" enter total number of test cases ";
    cin>>T;

    while(T--)
    {
        int N,d;

        cout<<" enter the value of N between (1 and 16)";
        cin>>N;

        int A[16]={0,0,1,0,2,0,2,2,1,6,0,5,0,2,6,5},i;


        d=counti(A,N);



        cout<<d<<endl;
    }

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire