Sigsegv error in question FLOW001

my code runs for test cases but gives runtime error id don’t know why or please help me to resolve this .THANK YOU IN ADVANCE
#include<bits/stdc++.h>
using namespace std;
int main()
{
long int i,n,a[10],b[10];
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i];
cin>>b[i];
}
for(i=0;i<n;i++)
{
int sum = a[i]+b[i];
cout<<sum<<endl;
}
return 0;
}

Ur printing all test case answers in last test case.but u have to individually print for each test case.So remove that extra for loop calculate sum and print it in first loop only.Actually there is no need of array ,he told u to print sum of two numbers so in that first for loop scan two variables and print a+b and ur problem is done and n limit is 1000

1 Like

Tell me this, why you have created an array of fixed size i.e. a[10] and b[10] and n as variable.
What if the value of n \gt 10, that’s the reason you are getting SIGSEGV error.

It’s a simple problem, why you are making it complicated? :slight_smile:

Thanks for Reading
Peace :v: