The logic in your for-loop is incorrect.
Below is an example to make it work;
Variable i in outer loop is to determine what int values to handle, such as 1, 2, 3 if n=3
The inner loop is to handle pow expression for a given i, such as 1^1, 2^2 and 3^3 as you mentioned.
for(i=1;i<=n;i++)
{
exp = 1;
for(j=1;j<=i;j++)
{
exp *=i;
}
s+=exp;
}