ARMSTRONG NUMBER
An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371. Also in the above image, we can see the example of Armstrong number.
C language code for Armstrong no:-
#include<stdio.h>
#include<conio.h>
void main()
{
int a,n,b=0,t;
clrscr();
printf("Enter the number\n");
scanf("%d",&n);
t=n;
while(n>0)
{
a=n%10;
n=n/10;
b=b+a*a;
}
if(b==t)
printf("armstorng no");
else
printf("not an armstrong");
getch();
return 0;
}
------------------------------------------------------------------------------------------------------------------
Output:
Enter the number:153
Armstrong no
Enter the number:435
not an armstrong
C language code for Armstrong Number
Reviewed by Amit Waghmare
on
January 04, 2019
Rating:
No comments: