Time limit exceeding in conversion of bin to dec

#include
using namespace std;

int dec(int m)
{
int x=0;
int p=2;
while(m>0)
{
int a=m%10;
int m=m/10;
int x=x+(ap);
p=p
2;

}
return x;

}
int main()
{
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
cout<<dec(n)<<endl;
}
return 0;
}

wrote this for conversion from binary to decimal
and two warnings are being raised
time limit exceed
how do i solve this

ok let me check your code @shreyakulkarni91

there were few mistakes i corrected the code and commented the mistakes


hope it is now cleared if yes don’t forget to mark it as resolved in my doubts section @shreyakulkarni91 :smiley:

@shreyakulkarni91 if your doubt is cleared please mark it as resolved