This is a program of while loop in which we are going to verify if the given number is an Armstrong number or not with the help of the C Programming language.
#include <stdio.h>
int main()
{
int num, n, r, result = 0;
printf("Enter a three-digit integer: ");
scanf("%d", &num);
n = num;
while (n != 0)
{
// remainder contains the last digit
r = n % 10;
result += r * r * r;
// removing last digit from the orignal number
n /= 10;
}
if (result == num)
{
printf("%d is an Armstrong number.", num);
}
else
{
printf("%d is not an Armstrong number.", num);
}
return 0;
}
//......Coded by ARADHANA MISHRA
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP