Sunday, October 16, 2011

Armstrong Number

#include<stdio.h>
#include<conio.h> 
void main()
{
    int n,d,t,sum=0;
    clrscr();
    printf("\tEnter a no.");
    scanf("%d",&n);
    t=n;
    while(n!=0) 
    {
d=n%10;
sum=sum+d*d*d;
n=n/10;
     }
    if(sum==t)
    printf("The No. %d is Armstrong Number",t);
    else
    printf("The No. %d is not an Armstrong Number",t);
    getch();
  }

No comments:

Post a Comment