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";
}
}
Comments
Post a Comment