Q. Write a C Program to check given number is armstrong number or not
What is Armstrong Number?
– An Armstrong number is a number of three digits which is an integer such that sum of the cubes of its digits is equal to the number itself.
For example,
153 is an Armstrong number, i.e
= 13 + 53 + 33
=((1*1*1)+(5*5*5)+(3*3*3))
= 1 + 125 + 27
=153
Other armstrong numbers are 0, 1, 370, 407…
Source Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int no1,no2,rem,sum=0;
clrscr();
printf("ntEnter Number : ");
scanf("%d",&no1);
no2=no1;
while(no1>0)
{
rem=no1%10;
sum=sum+(rem*rem*rem);
no1=no1/10;
}
if(sum==no2)
printf("nntGiven number is Armstrong !");
else
printf("nntGiven number is Not Armstrong !");
getch();
}
Output:



excellent !!!!!!
it is very helpful for students ….
Thanks
Keep visiting..:) Like us on Facebook !