Your logic of result*=devided;
is wrong. You need to add the digit(multiplied by it’s 10’s place) to the result. Here is the solution to your problem.
int function (int *n, int i){
int temp=n[i]; //tepmorary veraible of the passed number
int result=0;
int mult=1;
int devided;
while (temp!=0){
devided=temp%10;//get the last number example 123 = 3;
if (devided==9){ //if its 9 change the last didigt to 7
devided=7;
}
result+=(devided * mult);//multiply the last didgit with 10
temp/=10;
mult*=10;
}
return result;
}
3
solved How to transform the digits of a number?