Skip to content
Home » C Programs » Armstrong Number Program in C Using While Loop

Armstrong Number Program in C Using While Loop

Simple program to armstrong number program in c using while loop. This program will help you to find the number is Armstrong number or not in C. Here is the program to check whether the number is an Armstrong number or not an Armstrong number. An Armstrong three-digit number is an integer in which the total of its digits’ cubes equals the number itself. 371 is an Armstrong number, for example, since 3**3 + 7**3 + 1**3 Equals 371.

Armstrong Number

An Armstrong number, also known as a narcissistic number, is a number that equals the sum of its own digits’ cubes. 370, for example, is an Armstrong number because it equals 3*3*3 + 7*7*7 + 0*0*0.

While Loop in C

A “While” Loop is used to iterate over a specific block of code until a condition is met. The condition is evaluated first in a while loop, and if it returns true, the statements within the while loop are executed; this is repeated until the condition returns false. When the condition returns false, the control exits the loop and proceeds to the next statement in the program following the while loop. Here we have executed the armstrong number program in c using while loop for beginners to understand the programming concepts in c programming language.

If Else Definition in C

If a specified condition is true, the if/else statement executes a block of code. If the condition is not met, another block of code can be run. In C, the if-else statement is used to perform operations based on a specific condition. If and only if the given condition is true, the operations specified in the if block are carried out. 

Armstrong Number Program in C Using While Loop

#include <stdio.h>
int main() 
int num, a, rem, result = 0;
printf("Enter the number ");
scanf("%d", &num);
a = num;
while (a != 0) 
rem = a % 10;
result += rem * rem * rem;
a /= 10;
if (result == num)
printf("%d is an Armstrong number.", num);
printf("%d is not an Armstrong number.", num);
return 0;


Enter a three-digit integer:


456 is not an Armstrong number