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,
- Program:To check if a character is vowel or not (using if-else Statement)
- Program: To find greatest Of Three Using nested If-else Statement
- Program: WAP To Check A Number is Armstrong or Not
- Program: To print Fibonacci series
- Program:To print the table of number in c++
- Program: Multiplication of Matrices
0 comments:
Post a Comment