Why my code is showing segmentation fault?

#include
#include
#include<math.h>
using namespace std;

int main()
{
int n,i,j=0,a[100],b[100],sum=0;
b[100]={0};
cin>>n;
for(i=0; i<n; i++)
{
cin>>a[i];
}
for(i=0; i<n; i++)
{
while(a[i]>0)
{
if( (a[i] & 1) == 1 )
{
b[j]+=1;
j++;
a[i]>>1;
}
else
{
b[j]+=0;
j++;
a[i]>>1;
}
}
j=0;
}
for(i=0; i<64; i++)
{
b[i]=b[i]%3;
sum+=b[i]*pow(2,i);
}
cout<<sum;
return 0;
}

hello @jatin_wadhwa
a) check maximum value of n possible and declare size of array a accordingly.
b) initialise b array with 0.
c)
initialise j with 0 inside this for loop.

d) replace a[i]>>1 with a[i]=a[i]>>1;