Friday, 24 July 2015

C Program - To check the 'Armstrong Number'

C Program to check the 'Armstrong Number'



#include<stdio.h>
#include<conio.h>
void main()
{
int rem,temp,n,arm=0;
clrscr();
printf("\nEnter any number :- ");
scanf("%d",&n);
temp=n;
while(temp!=0)
{
rem=temp%10;
arm=arm+rem*rem*rem;
temp=temp/10;
}
if(n==arm)
{
printf("\nThe given number is armstrong number");
}
else
{
printf("\nThe given number is non-armstrong number");
}
getch();
}

Output :- 



Back to 'C Language Programs'

No comments:

Post a Comment