C Program to Check whether entered number is Armstrong Number or not
here is an Example to check whether an integer entered by the user is an Armstrong number or not using while loop and if…else statement.
Before going to write the c program to check whether the number is Armstrong or not, let’s understand what is Armstrong number.
Armstrong numberisa number that is equal to the sum of cubes of its digits. in other words An Armstrong number is an n-digit base b number such that the sum of its (base b) digits raised to the power n is the number itself. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.
as it is often asked is exams to write a program to check weather the entered number is Armstrong or not
so let us understand with the help of examples then we will check its code
Let’s check the c program to check Armstrong Number in C
int number, sum = 0, rem = 0, cube = 0, temp;
printf ("enter a number : - ");
temp = number;
while (number != 0)
rem = number % 10;
cube = pow(rem, 3);
sum = sum + cube;
number = number / 10;
if (sum == temp)
printf ("The given no is armstrong");
printf ("The given no is not a armstrong");
enter the number=153
The given no is armstrong
enter the number=5
The given no is not a armstrong