Exception has occurred. Segmentation fault error

I am getting error Exception has occurred. Segmentation fault on LINE 16. What is causing this error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
using namespace std;
int main()
{
    int arr[5];
    int sum[5];
    int s=0;
    for(int i=0; i<5; i++)
    {
        cin>>arr[i];
    }
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; i < 5; j++)
        {
            if(arr[j]==arr[i])
            {
                continue;
            }
            s=s+arr[j];
        }
        sum[i]=s; 
    }
    //sorting array
    for(int i=0;i<5;i++)
	{		
		for(int j=i+1;j<5;j++)
		{
			if(sum[i]>arr[j])
			{
				int temp  =sum[i];
				sum[i]=sum[j];
				sum[j]=temp;
			}
		}
	}
    cout<<"Minimum sum is "<<sum[0]<<" and maximum sum is "<<sum[4];
    
    return 0;
}
See line 14 and look VERY CAREFULLY!
Figured it out Thanks :)
Topic archived. No new replies allowed.