Armstrong Number For 3 Digits

in Hindi - Armstrong Number For 3 Digits



not yet

Source Code :

RUN#include <iostream>
using namespace std;

int main()
{
int num1,num2, num3=0, ans ;

cout<<"Enter Number : ";
cin>>num1;

num2=num1;

while(num2!=0){

ans = num2 % 10;
num3 = num3 + ans * ans * ans ;
num2 = num2 / 10;
}

if(num1 == num3){
cout<<num1<<" is an Armstrong number";
}
else{
cout<<num1<<" is not an Armstrong number";
}
return 0;
}