## CodeChef runtime error(sigsegv)

runtime error - sigsegv hackerearth
sigemt error in codechef
sigtstp codechef
runtime error(other) codechef
runtime error sigabrt
runtime error sigfpe
codechef c++
segmentation fault (sigsegv)

CodeChef Problem:

Shivam is the youngest programmer in the world, he is just 12 years old. Shivam is learning programming and today he is writing his first program.

Program is very simple, Given two integers A and B, write a program to add these two numbers.

Input The first line contains an integer T, total number of test cases. Then follow T lines, each line contains two Integers A and B.

Output Add A and B and display it.

Constraints 1 ≤ T ≤ 1000 1 ≤ A,B ≤ 10000 Example Input 3 1 2 100 200 10 40

Output 3 300 50

```#include <stdio.h>
int main()
{
int T, A, B, i, sum[T];
scanf("%d", &T);
for(i=0;i<T;i++)
{
scanf("%d",&A);
scanf("%d",&B);
sum[i]=A+B;
}

for(i=0;i<T;i++)
{
printf("\n%d", sum[i]);
}

}
```

Error Runtime Error SIGSEGV - I searched it, it says array out of bounds.

`T` has an indeterminate value when you declare `sum[T]`. Instead, do:

```int main()
{
int T, A, B, i;
scanf("%d", &T);
int sum[T];
for(i=0;i<T;i++) ...
```

Ans you should check the return value of `scanf`.

Why do I get a SIGSEGV? - faq, Why I am getting a runtime error SIGSEGV in the problem? Where I am going wrong? CodeChef Problem: Shivam is the youngest programmer in the world, he is just 12 years old. Shivam is learning programming and today he is writing his first program.

If you want to allocate the memory runtime (during the programs execution) it would be more appropriate to use a function such as "malloc". Here is a short example.

```#include <stdio.h>
#include <stdlib.h>

int main()
{
int T, A, B, i;
int *sum;

scanf("%d", &T);
if (T <= 0) /*Check if the value of T is appropriate*/
{
fprintf(stderr, "Invalid argument T!\n");
}

/* Dynamically allocate the memory */
sum = (int *)malloc(sizeof(int)*T);
if (sum == NULL)
{
fprintf(stderr, "Failed to allocate memory!\n");
}

for(i=0;i<T;i++)
{
scanf("%d",&A);
scanf("%d",&B);
sum[i]=A+B;
}

for(i=0;i<T;i++)
{
printf("\n%d", sum[i]);
}

/* Free the allocated memory once you are not needing it anymore in
order to avoid memory leaks */
free(sum);

return (0);
}
```

Note: This is just an example how to avoid the runtime error I have not taken a close look at the rest of the logic related with the for loops.

Getting Runtime Error(SIGSEGV) on Code Chef, can't find out what's , Y is this a runtime error?? #include #include int main() { int t,n,p,i,j,e,h,s; clrscr​(); printf("\nEnter the no. of test cases:"); scanf("%d",&t); for(i=0;i =p/2) e++; else  Thanks to a friend, I found out the issue is that I have declared . int c[INGREDIENT]={0}; where INGREDIENT = 4 But I am trying to access beyond the limit of 4 elements, everytime the variable 'pairs' is greater than 4

Declare sum[T] after taking the input value of T

Why am I getting a runtime error (SIGSEGV) when I submit my , There are many problems with your code , Note that the values of N can be as large as 10^5. 1 ≤ N ≤ 100000 (10^5). 1 ≤ Q ≤ 5000 (5 · 10^3). 1 ≤ K ≤ 20. CodeChef - A Platform for Aspiring Programmers CodeChef was created as a platform to help programmers make it big in the world of algorithms , computer programming , and programming contests . At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and two smaller programming challenges at the middle and end of the month.

Sphere Online Judge (SPOJ), Why am I getting a runtime error (SIGSEGV) when I submit my solution on CodeChef or Sphere Online Judge (SPOJ), while it's working fine and even giving the  Questions and answers about sigsegv on CodeChef Discuss. You are not logged in. Please login at www.codechef.com to post your questions!

why is the code showing runtime error SIGSEGV, What is segmentation fault? This tutorial is based on main SPOJ, but there are also sub-domains dedicated to Vietnamese, Brazilian RE - runtime error - your program was compiled successfully, but it exited with a runtime error or crashed. Follow this question By Email: Once you sign in you will be able to subscribe for any updates here. By RSS: Answers Answers and Comments

Online Judge, the code isn't showing any error on codechef ide nd also giving correct output,,,,,​bt on submission its showing runtime error SIGSEGV,,,,,whats  CodeChef is a non-profit competitive programming community. CodeChef - A Platform for Aspiring Programmers. CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests.

• And what is the value of `T` when you declare `sum[T]`?
• I'm taking `T` as user input.