If u also want to store that array ie. (2^i)%mod [i=0 to whatever] than:
long mod = 1000000007;
long int pow_mod[ele]; //here 'ele' = maximum power upto which you want to store 2^i
pow_mod[0]=1; //2^0 = 1
for(int i=1;i
I hope it'll be helpful to someone.