Hello !

I need some help with this code(my program should display the last digit of the sum
2^a + 3^a +...+9^a - where a is a number entered from the keyboard):
Code:
#include <iostream>
using namespace std;

int main()
{
	int a,n,i,p = 1,uc,s = 0;
	cout << "a = ";
	cin >> a;
	if (a == 0) cout << "8" << endl;
	
	for (n = 2;n <= 9;n++) {
	for (i = 1;i <= n;i++) {
	p = p*n;
	uc = p%10;
	p = p%10;
	s = s+uc;
	}
	}
	cout << s << endl;
	return 0;
}
What's wrong with my code ? The program doesn't work.
I would be grateful if you would explain to me what I did wrong.

: