All Test Cases Failed

#include<bits/stdc++.h>
using namespace std;

int main(){
long long int num,temp,n=0,check=0;
cin>>num;
temp=num;
while(temp){
n++;
temp=temp/10;
}

temp=num;

while(temp){
    int remainder=temp%10;
    temp=temp/10;
    int toadd=1;
    for(int i=0;i<n;i++){
        toadd*=remainder;
    }
    check+=toadd;
}

if(check==num){
    cout<<"True"<<endl;
}
else{
    cout<<"False"<<endl;
}
return 0;

}

hey @nakshjain
your logic was absolutely correct, just a small mistake. according to question u are supposed to print output whole in lowercase, while u are printing True, False where first letter is capital. Just correct it and your code will pass all test cases…

Corrected code–>

#include<bits/stdc++.h>
using namespace std;

int main(){
    int num,temp,n=0,check=0;
    cin>>num;
    temp=num;
    while(temp){
        n++;
        temp=temp/10;
    }

    temp=num;

    while(temp){
        int remainder=temp%10;
        temp=temp/10;
        int toadd=1;
        for(int i=0;i<n;i++){
            toadd*=remainder;
        }
        check+=toadd;
    }

    if(check==num){
        cout<<"true"<<endl;
    }
    else{
        cout<<"false"<<endl;
    }
    return 0;
}

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.