Monday 17 April 2017

How to write a program for Armstrong number in C .

Dear Students ,

  It's a very simple for you . First of all , we need to know that what is ARMSTRONG number .Did you know ? If yes ,"It's very Good " and if you don't know ,"No Worry ".Let's See....


    Armstrong numbers are those number which is calculate with each other of Que of Digits and Find out the total of these calculation if total equal your number .  

For Example :

  153 = 1*1*1+5*5*5+3*3*3

  153  = 153

 R.H.S=L.H.S

Example :

   #include<stdio.h>
   #include<conio.h>
   void main()
   {
     int num,rem,temp,sum=0;
     printf("Enter your Number : ");
     scanf("%d",&num);
     temp=num;
    while(num>0)
      {
         rem=num%10;
         sum=sum+rem*rem*rem;
         num=num/10;
      }

       if(temp==sum)
       {
           printf("Number is Armstrong .");
       }
       else
        {
           printf("Number is Not Armstrong ");
        }
      getch();
}


Your OutPut :
  

No comments:

Post a Comment