Armstrong number:
Also known as narcissistic numbers, Armstrong numbers are the sum of their own digits to the power of the number of digits. As that is a slightly brief wording, let me give an example:
153 = 1³ + 5³ + 3³
Now here is the C++ programming to check whether a number is Armstrong or not .
Also known as narcissistic numbers, Armstrong numbers are the sum of their own digits to the power of the number of digits. As that is a slightly brief wording, let me give an example:
153 = 1³ + 5³ + 3³
Now here is the C++ programming to check whether a number is Armstrong or not .
CODE:
#include<iostream.h> #include<conio.h> void main() { int Number,Temp,b=0; cout<<endl<<"Enter any number to check"; cin>>Number; Temp=Number; int P; while(Temp>0) { P=Temp%10; b=b P*P*P; Temp=Temp/10; } if(b==Number) { Cout<<endl<<"Armstrong no"; } else { cout<<"Not an armstrong no"; } getch(); }
For any Queries related to this Program ,Drop a comment.
For Further Reading,
0 comments:
Post a Comment