Check the Scientist

Description:

Armstrong was one of the great scientist. The Indian council decided that we need to assign some number as a gift to the great scientist. There was a suggestion given by the Indian Council. If the sum of cube of each number is again equal to the number then they decided that they can assign the number to the great scientist. Kindly help the Indian Council to complete the task by writing a simple logic. Refer sample Input and Output: Input 1: 153 Output: Give to Scientist Armstrong Reason((1*1*1 + 5*5*5 3*3*3=153) which is equal to the number) Input 2 153 Output: Dont Give to Scientist Armstrong Reason((1*1*1 + 5*5*5 2*2*2=134) which is not equal to the number ) Test Case 1 Input (stdin) 53 Expected Output Dont Give to Scientist Armstrong Test Case 2 Input (stdin) 153 Expected Output Give to Scientist Armstrong

Program :


#include <iostream>

using namespace std;

int main()

{

 int n,r,s=0,t;

  cin>>n;

  t=n;

  while(n>0)

  {

    r=n%10;

    s=s+(r*r*r);

    n=n/10;

  }

  if(t==s)

    cout<<"Give to Scientist Armstrong";

  else

    cout<<"Dont Give to Scientist Armstrong";

return 0;

}