Thursday, November 22, 2012

C PROGRAM FOR ARMSTRONG NUMBER



/*  C PROGRAM FOR  ARMSTRONG NUMBER */


#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
     int s,x,i,n;
     clrscr();
     printf("\n\t\tARMSTRONG NUMBER");
     printf("\n\t\t~~~~~~~~~~~~~~~~");
     printf("Armstrong no's are\n");

       for(i=100;i<=1000;i++)
      {
         s=0;
         x=i;

          while(x>0)
          {
              n=x%10;                      
              x=x/10;                  
               s+=pow(n,3);             
           }                       

            if(i==s)                
            printf("%d\n\n",i);     
       }                       
     getch();
}                     

             















OUTPUT:



ARMSTRONG NUMBER
  
 Armstrong no's are:

153

370

371

407


0 comments:

Post a Comment