Follow Us

LightBlog

Breaking

Thursday, January 12, 2017

Armstrong number

        write a program to find the Armstrong number using c 

           #include<stdio.h>
           void main()
            {
       int n,temp,r,sum=0;
       printf("enter a number to check  an armstrong number \n");
       scanf("%d",&n);
       temp=n;
while(temp!=0)
       {
r=temp%10;
sum=sum+r*r*r;
temp=temp/10;
     } 
         if(n==sum)
          {
              printf("%d is an armstrong number",n);
                    }
    else
          {
            printf("%d is not an armstrong number",n);
                    }
   getch();
  }

No comments:

Post a Comment