I have written a P
function that removes c
digits in an n
integer number.
The head of the function is : void P(int &n, int &c)
.
Let's say n = 23734 and c = 3
The output should be: 274
This what i have tried before asking here.
void P(int &n,int &c) {
int p=1,k=0;
while(n)
{
if(n%10==c)
n=n/10;
else
{
k=k+n%10*10;
n=n/10;
}
}
cout<<k;
}
P.S. I am new here that's why i don't know how to correctly add codes.