Armstrong Number In C++

*. ArmStrong Number :-

ArmStrong Number is equal to the sum of cube of its all digits


#.Code :-


#include<iostream>
using namespace std;
int main(){
    /*ArmStrong Number are the number whose addition of cube of
every digit is equal to that number*/
    int num;
    cout<<"Enter  a num : ";
    cin>>num;
    const int num2=num;
    int store;
    int str;
    int arm_num=0;
    while(num>0){
        store=num%10;
        str=(store*store*store);
        arm_num+=str;
        num= num/10;
    }
    if(num2==arm_num){
        cout<<num2<<" is armstrong number ";
    }
    else{
        cout<<num2<<" is not armstrong number";
    }
}



Output :-






Comments

Popular posts from this blog

To do addition of all the Elements of Array in C++

A program to Search element in array , and if repeated so at which location it is present and how many time the number is repeated

Take n no. Of elements and arrange them in Ascending & Descending Order