GoogelAddUnit1

Thursday 10 March 2011

C Program to calculate Amstrong number.?


/* Armstrong number */                                                                    

#include<stdio.h>
#include<conio.h>
main()
{
    int n,d,s=0,k;
    printf("\n enter the value");
    scanf("%d",            &n);
    k=n;
    while(n!=0)
    {
     d=n%10;
     n=n/10;
     s=s+(d*d*d);
    }
    if(k==s)
      printf("\n it is armstrong");
    else
      printf("\n it is not armstrong");
    getch();
}

No comments:

Post a Comment