Problem: https://online.codingblocks.com/app/player/158507/content/150879/4790/code-challenge#
// Program to check if a number is armstrong number
#include<iostream>
#include<cmath>
using namespace std;
bool checkArm(long long int n)
{
long long int temp = n;
int sum = 0;
while (n>0)
{
long long int a = n%10;
sum += a*a*a;
n /= 10;
}
if (sum == temp)
return true;
else
return false;
}
int main()
{
long long int n;
cin>>n;
if(checkArm(n))
cout<<"true"<<endl;
else
cout<<"false"<<endl;
return 0;
}
Its giving me errors in Test Case 0 and Test Case 1. But its giving me correct answers. Kindly help!