Segmentation fault(core dumped)PZZhelp

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,k,T,N[10],S[10];

 scanf("%d",&T);
 for(i=0;i<T;i++)
     {
     	
     scanf("%d",&N[i]);
     }
for(j=0;j<T;j++)
    {
     S[i]=(N[i]*(N[i]+1))/2;
    }
for(k=0;k<T;i++)
    {
    printf("%d\n",S[i]);
}
getch();
return 0;

}

In your second loop you are looping through j but inside the loop you are using i which should be equal to T by the end of the first loop. And in the third loop you increase i while checking the condition for k. If that’s intentional you should say what you’re trying to do with this code or what problem you’re trying to solve.

1 Like
//