How to find a given number is armstrong number or not in "c".?

Showing Answers 1 - 5 of 5 Answers

pavan

  • Jul 24th, 2006
 

ex:: 153=cube(1)+cube(5)+cubeof(3)

  Was this answer useful?  Yes

pari

  • Jul 25th, 2006
 

given no ,n=153,

n1=n;    while(n>=0) {

      r=n%10;

     sum+=r*r*r;

     n=n/10;}

if(n1==sum)then armstrong else not

     

  Was this answer useful?  Yes

shubhramani mazumdar

  • Jul 26th, 2006
 

to find a number as armstrong or not by dividing the number by 10 and take the remainder and take the cube of the remainder and store it in a variable.countinue with it until the number become zero.

  Was this answer useful?  Yes

Deepak kumar Prasad

  • Aug 7th, 2006
 

The check should should be

while ( n>=1) and not (n>=0)
The cotrol enters into an infinite while loop.

  Was this answer useful?  Yes

jintojos

  • Jun 16th, 2008
 

void main() { int num1,num2,sum=0,rem; printf("Enter The Number :"); scanf("%d",&num1); num2=num1; while(num2>0) { rem=num2%10; sum+=rem*rem*rem; num2/=10; } if(sum==num1) printf("Amstrong Number..."); else printf("Not Amstrong Number...");

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions