C++ Program:

- To check number is Armstrong or not

Example:

User Input:1

Output: Armstrong Number

#include <iostream>
using namespace std;

int main() {
  int num,num2,digit,sum=0;
  cout<<"Enter Your number : ";
  cin>>num;
  num2=num;
  while(num!=0){
    digit=num%10;
    sum= sum + digit*digit*digit;
    num/=10;
  }
  if(num2==sum)cout<<"Armstrong Number";
  else cout<<"Not a Armstrong Number";
  return 0;
}

Output:

  Enter Your number : 407
  Armstrong Number
Program
number

You must know first,

Armstrong Number : if a number & cube of every single digit of the number are equal than the number is an Armstrong number

Example :

Number: 407 & cube of every single digit = 407. so it's an Armstrong Number
(4*4*4)+(0*0*0)+(7*7*7) = 64+0+343 = 407

//Save the original number
  num2=num;

//find every single digit & add the cube of it
  while(num!=0){
  digit=num%10;
  sum=sum + digit*digit*digit;
  num/=10;
}

//check for the Armstrong
if(num2==sum)
Concept

Coming Soon !

Quick
Tutorial

Quote

The best preparation for good work tomorrow is to do good work today.