To find the given number is armstrong
(or) not
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n, r, s = 0, t;
clrscr();
printf("Enter a number : ");
scanf("%d", &n);
t = n;
while(n > 0)
{
r = n % 10;
s = s + (r * r * r);
n = n / 10;
}
if(s == t)
printf("\n%d is an armstrong number", t);
else
printf("\n%d is not an armstrong number", t);
getch();
}
Output:
Case: 1
Enter a number : 153
153 is an armstrong number
Case: 2
Enter a number : 123
123 is not an armstrong number
-
UpdatedDec 30, 2019
-
Views6,257
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order