Monday, 17 June 2013

Check Armstrong Number – C SOURCE CODING

Check Armstrong Number – C SOURCE CODING


ARMSTRONG NUMBERS:


An Armstrong number of Three Digits is an integer Such that the Sum of the Cubes of its Digits is Equal to the Number itself.


Example: 371 is an Armstrong Number Since 3**3 + 7**3 + 1**3 = 371.

ARMSTRONG NUMBER

void main()


{


int n,b=0,t;


clrscr();


printf(“Enter the no”);


scanf(“%d”,&n);


t=n;


while(n>0)


{


a=n%10;


b=b+a*a*a;


n=n/10;


}


if(b==t)


{


printf(“Armstrong no”);


}


else


{


printf(“Not an armstrong no”);


}


getch();


}


Check Armstrong Number – C SOURCE CODING

0 comments:

Post a Comment

    Followers