DarkWebCode is a place where you can find a lot of exciting and inspiring stuff about Web Development, Blogging, SEO and many more

Breaking

C Program to check the given number is Armstrong number or not.

AIM : 
             To write a C Program to check the given number is Armstrong number or not.

ALGORITHM :
       
                 1.Start
                 2.Read n.
                 3.Store n into another variable num.
                 4. if n!=0 then calculate
                          r=n%10
                          sum=sum+r*r*r
                          n=n/10
                 5.Check whether sum equal to or not.If both number is armstrong number.
                 6. Otherwise print not Armstrong number.
                 7.Stop.

PROGRAM : 

#include<stdio.h>
#include<conio.h>
void main()
{
           int n,sum,r,num;
           sum=0;
           printf("Enter the number : ");
           scanf("%d",&n);
           num=n;
           while((n!=0)
           {
                r=n%10;
                sum=sum+r*r*r;
                n=n/10;
           }
           if(sum==num)
          {
                printf("Entered number is armstrong number");
           }
           else
          {
                printf("Entered number is not armstrong number");
          }
}

http://www.programhub.in/2017/09/c-program-to-check-given-number-is.html