please explain me line no 16 and 21 in the code
Please explain line 16 and 21 in the code
int digit=in[i]-‘0’;
// if( digit==0)
//{
// print(in,out,i+1,j);
//}
in line no 16 (int digit=in[i]-‘0’;
as in['i] is character but we need integer for further processing
for example if in[i]=‘6’ then internally it contains ascii value of ‘6’ which is 54 so to get 6 from this we subtract it with ascii value of ‘0’ which is 48 hence 54-48=6.
as in question it is stated: string corresponding to 0 is " " (empty string) means nothing
so we do nothing when digit is 0;
also explain the code:
for(int k=0;keypad[digit][k]!=’\0’;k++)
{
out[j]= keypad[digit][k];
print(in ,out, i+1, j+1);
}
}
in these lines we are trying to place each character corresponding to the digit
and then call for recursive function
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.