Showing posts with label Arms Strong Number in C. Show all posts
Showing posts with label Arms Strong Number in C. Show all posts

Thursday, May 3, 2012

Whether the given no. is armstrong or not


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



Output of this Program is:
Dont forget to give any Suggestion or Comments