C Program to Check a Given Number is a Armstrong or not

An Armstrong number (also known as a narcissistic number, pluperfect number, or pluperfect digital invariant) is a number that is the sum of its own digits each raised to the power of the number of digits. For example, 153 is an Armstrong number .

Here’s a simple C program to check if a given number is an Armstrong number:

Program :

#include<stdio.h>
#include<conio.h>
void main()
{
int a,n,b=0,t;
printf(“Enter the number : “);
scanf(“%d”,&n);
t=n;
while(n>0)
{
a=n%10;
b=b+a*a*a;
n=n/10;
}
if(b==t)
{
printf(“%d is a Armstrong Number.”,t);
}
else
{
printf(“%d is not an Armstrong Number.”,t);
}
}

Output :

Leave a Comment

Your email address will not be published.

Shopping Basket
Verified by MonsterInsights