Armstrong Number:
An Armstrong number (after Michael F. Armstrong) or a narcissistic number (also known as a pluperfect digital invariant (PPDI), or a plus perfect number) is a number that is the sum of its own digits each raised to the power of the number of digits.
Program:
#include<stdio.h>
void main()
{
int n,rem=0,sum=0,a;
clrscr();
printf("Enter the number:");
scanf("%d",&n);
a=n;
while(n>0)
{
rem=n%10;
sum=sum+rem*rem*rem;
n=n/10;
}
if(a==sum)
printf("%d is an Armstrong number",a);
else
printf("%d is not an Armstrong number",a);
getch();
}
An Armstrong number (after Michael F. Armstrong) or a narcissistic number (also known as a pluperfect digital invariant (PPDI), or a plus perfect number) is a number that is the sum of its own digits each raised to the power of the number of digits.
Program:
#include<stdio.h>
void main()
{
int n,rem=0,sum=0,a;
clrscr();
printf("Enter the number:");
scanf("%d",&n);
a=n;
while(n>0)
{
rem=n%10;
sum=sum+rem*rem*rem;
n=n/10;
}
if(a==sum)
printf("%d is an Armstrong number",a);
else
printf("%d is not an Armstrong number",a);
getch();
}
No comments:
Post a Comment