Write a program to find Armstrong number 153 or 371?

Questions by Aniket Rawat

Showing Answers 1 - 12 of 12 Answers

Manohar

  • Aug 5th, 2011
 

Code
  1. # include<math.h>

  2. main()

  3. {

  4. int n=153,rem,sum=0;

  5. while(n>0)

  6. {

  7. rem=n%10;

  8. sum=sum+pow(rem,3);

  9. n=n/10;

  10. }

  11. printf("%d",sum);}

  Was this answer useful?  Yes

Code
  1. #include<stdio.h>

  2. void main()

  3. {

  4. int n=370;

  5. int a,b,c,d,e;

  6. a=n%100;

  7. b=n/100;

  8. c=a%10;

  9. d=a/10;

  10. e=(b*b*b)+(c*c*c)+(d*d*d);

  11. if(e==370)

  12.  

  13. printf("the given no is Armstrong no.%d",e);

  14.  

  15. else

  16.  

  17. printf("the given no is NOT Armstrong no.%d",e);

  18.  

  19. return 0;

  20. }


  Was this answer useful?  Yes

nirosha

  • Aug 17th, 2011
 

153 is the armstrong nummber

Code
  1. #include<stdio.h>

  2. void main()

  3. {

  4.      int n,sum=0,r;

  5.      clrscr();

  6.      printf("Enter your number");

  7.      scanf("%d",&n);

  8.      if(n>0)

  9.      {

  10.              r=n%10;

  11.              sum=sum+r*r*r;

  12.              n=n/10;

  13.       }

  14.       printf("%d",sum);

  15.       getch();

  16. }

  17.  

  Was this answer useful?  Yes

Tanuja Jaiswal

  • Jan 26th, 2012
 

Code
  1. #include<stdio.h>

  2. #include<conio.h>

  3. void main()

  4. {

  5. int num,digit,sum=0;

  6. printf("Enter any number ");

  7. scanf("%d",&num);

  8. while(num!=0)

  9. {digit=num%10;

  10. sum=sum+(digit*digit*digit);

  11. num=num/10;

  12. }

  13. if(sum==num)

  14.   printf("The number %d is armstrong",num);

  15. else

  16.   printf("The number %d is armstrong",num);

  17. getch();

  18. }

  19.  

  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