# C Program to Check if Give Number is Armstrong or Not using While loop

## Write C Program to Check if Give Number is Armstrong or Not using While loop

//Write a C program to check the given number is Armstrong or not

#include <stdio.h>

int main()
{
int n, ans = 0;

printf("Enter the number:--> ");
scanf("%d", &n);

int temp = n;
while(n != 0)
{
int remainder = n % 10;
ans = ans + (remainder * remainder * remainder);
n = n / 10;
}
if(temp == ans)
{
printf("The given number is an Armstrong number");
}
else
{
printf("The given number is not an Armstrong number");
}

return 0;
}


Output:

Run 1:
Enter the number:--> 372
The given number is not an Armstrong number

Run 2:
Enter the number:--> 371
The given number is an Armstrong number