P^q mod c problem

compute p^q mod c

where,
test cases <=100
p,q,c<=100

how to solve this problem?

I have tried this but getting wrong ans, is there any other way?
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t–)
{
int p,q,c;
cin>>p>>q>>c;
int ans = 1;
for(int i=0; i<q; i++){
ans = (ans*p)%c;
}
cout<<"Result = "<<ans;
if(t!=0) cout<<endl;
}
return 0;
}

hello @tasfikrahman007 i am giving you the code below try this :
#include
using namespace std;

#define ll long long
int poww(ll a,ll b,ll c)
{
if(b==0)
return 1;

return (a*poww(a,b-1,c)%c);

}

int main()
{
ll a,b,c;
cin>>a>>b>>c;

ll t1=poww(a,b,c);
cout<<t1%c;

}

still not accepted, do we need to think about negative inputs?

please see the constraints and modift your code according to that .

there is no more constraints. :frowning:

please share the screenshot or copy paste the question here.

@tasfikrahman007 try now: