Table of Contents
C program to check Armstrong number
C program to check Armstrong number : If number is equal to sum of all digits where each digit is raise to the count of digits then it is Armstrong number e.g. 153, 370, 371.
Let’s take 371
total digits is 371 (n) = 3
then 33 x 73 x 13 = 371
#include <stdio.h>
#include <math.h>
void isArmstrong(int n)
{
int a = n, b = n, len = 0, rsl = 0, rem;
while(b!=0)
{
len++;
b/=10;
}
while(a!=0)
{
rem = a%10;
rsl += pow(rem,len);
a /= 10;
}
if(rsl == n)
{
printf("Yes!!! It is an Armstrong number");
}
else
{
printf("No!!! It is not an Armstrong number");
}
}
//itvoyagers.in
int main ()
{
int x;
printf("Enter any number : ");
scanf("%d",&x);
isArmstrong(x);
return 0;
}
Output :
Enter any number : 371
Yes!!! It is an Armstrong number
———————————–
Enter any number : 1634
Yes!!! It is an Armstrong number
PRACTICALS/PRACTICE PROGRAM IN C
CHECKOUT OTHER RELATED TOPICS
CHECKOUT OTHER QUIZZES
Quizzes on Operator |
Easy Quiz on Operators in C part 1 |
Easy quiz on operators in C part 2 |
Easy quiz on operators in C part 3 |
Quizzes on Loops |
Easy quiz on loops in C part 1 |
Easy quiz on loops in C part 2 |
Easy quiz on loops in C part 3 |
Quizzes on Decision Making Statement |
Easy Quiz On Decision Making Statements Part 1 |
Easy Quiz On Decision Making Statements Part 2 |
Quizzes on String |
Easy quiz on String in C programming part 1 |
Quizzes on Array |
Easy quiz on Array in C programming – part 1 |
5 – Best Java program to convert decimal to binary |
New Quizzes Coming soon.. |
We are aiming to explain all concepts of C in easiest terms as possible.

ITVoyagers
Author