i am getting SIGSEGV error in this beginner level question FCTRL2 Problem - CodeChef
Please tell me what to do next and how to solve this problem.
Here is my code…
#include
using namespace std;
int factorial(int n){
int fac=1;
while(n){
fac*=n;
n–;
}
return fac;
}
int main(){
int testcase,n,i=-1;
cin>>testcase;
int ans[5];
while(testcase){
i++;
cin>>n;
ans[i]=factorial(n);
–testcase;
}
for(int j=0;j<=i;j++)
cout<<endl<<ans[j];
return 0;
}