PROBELM FACING IN TEST CASES

MY 1 TEST CASE AND 2 ND TEST CASE IS NOT CORRECT WHY ??
PLEASE HELP ME IN THIS.

#include
using namespace std;
bool checkArmstrongNumber(int num);

int main(){
int num;
bool flag;
cout<<"Enter a positive integer: ";
cin>>num;
flag = checkArmstrongNumber(num);
if(flag == true)
cout<<“yes”;
else
cout<<“no”;

return 0;
}
bool checkArmstrongNumber(int num) {
int temp, sum=0, digit;
bool isArm;
temp = num;
while(temp != 0) {
digit = temp % 10;
sum = sum +(digit * digit * digit);
temp = temp/10;
}
if (sum==num)
isArm = true;
else
isArm = false;

return isArm;
}

hello @naval16

this is not required.
check output format of the given problem and then print only that thing which is mentioned in output format.

#include
using namespace std;
bool checkArmstrongNumber(int num);

int main(){
int num;
bool flag;
cin>>num;

//Calling function
flag = checkArmstrongNumber(num);
if(flag == true)
cout<<“yes”;
else
cout<<“no”;

return 0;
}
/* User defined function that checks whether the passed

  • integer number is Armstrong or not
    */
    bool checkArmstrongNumber(int num) {
    int temp, sum=0, digit;
    bool isArm;

    temp = num;
    while(temp != 0) {
    digit = temp % 10;
    sum = sum +(digit * digit * digit);
    temp = temp/10;
    }
    if (sum==num)
    isArm = true;
    else
    isArm = false;

    return isArm;
    }

IN THIS ALSO , FACING SAME PROBLEM .
ALL TEST CASES ARE WORKING PROPERLY EXCEPT 0 AND 1


MINE CODE IS THIS PLEASE HELP ME IN THIS .

image
pls check this .

#include
using namespace std;
int fastPow(int a, int b)
{
if(b==0)
return a;

int smallAns = fastPow(a, b/2);
smallAns *= smallAns;
if(b & 1)
     return smallAns*a;

 return smallAns;

}
bool isArmstrong(int n)
{
int noOfDigits = 0;
int m = n;
while (m)
{
noOfDigits++;
m /= 10;
}

m = n;
int sum = 0;
while (m)
{
    int r = m % 10;
    sum += fastPow(r, noOfDigits);
    m /= 10;
}

return n == sum;

}
int main()
{
int num;
cin>>num;
isArmstrong(num) ? cout<<“no”:cout<< “yes” ;

return 0;
}

please help me in this

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.