One test case fails please explain the error in the code

#include
using namespace std;
void find(long long int num){
long long int m=num;
if(m==0){
cout<<5;
}
else{
int i,counter=1,sum=0;
for( i=0,m;m!=0;m/=10,i++){
int r=m%10;
if(r==0){
r=5;
}
sum+=rcounter;
counter
=10;
}
cout<<sum;
}

}
int main(){
long long int num;
cin>>num;
find(num);

return 0;

}

hi @nitinchauhan0808_be04315530401452
corrected code–>

#include <iostream>
using namespace std;
void find(long long int num){
    long long int m=num;
    if(m==0){
         cout<<5;
    }
    else{
        long long int i,counter=1,sum=0;
        for( i=0,m;m!=0;m/=10,i++){
            int r=m%10;
            if(r==0){
                r=5;
            }
            sum+=r*counter;
            counter*=10;
        }
        cout<<sum;
    }
    
}
int main(){
    long long int num;
    cin>>num;
    find(num);
    
    return 0;
}

long long int i,counter=1,sum=0;
this change was required.

sir but why long long int is used in i.i is just a iterator in the loop

what is the use of long long int in i?

basically long long int is need for the sum=0, but since u have declared 3 variables together, make int as long long int. Or seperately write as long long int sum = 0;

Hey, is there anything else??

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.