Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Not able to identify the SIGSEGV Error in the code

A.Vik:

You have been given an Array A of size N consisting of positive integers.You need to find and print the product of all the number in this array Modulo 10^9+7.

Input Format:

The first line contains a single integer N denoting the size of the array. The next line contains N space separated integers denoting the elements of the array

Output Format:

Print a single integer denoting the product of all the elements of the array Modulo 10^9+7

Constraints:


1≤N≤10^3

1≤A[i]≤10^3

Sample Input:


5

1 2 3 4 5

Sample Output:


120

The code is working fine for the sample testcase but when I submit it on hackerearth it shows segmentation fault.I am unable to identify where the fault is.

I apologize if you find this a trivial question.

The code is:


#include
using namespace std;

int main()
{
int i,N;
int A[i];
int answer = 1;
cin >> N ;
for(int i=0;i {
cin >> A[i];
answer = (answer*A[i])%(int)(1000000007);
}
cout return 0;
}



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Not able to identify the SIGSEGV Error in the code

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×