Which are armstrong numbers?

Numbers whose sum of cube of digits is equal to the number itself.

e.g. if we take 153 than 

1=1

53=125

33=27    and sum of all of them is 1+125+27=153

so 153 is a armstrong number.

Code in c :

#include < stdio.h >

#include < conio.h >

  void main() {
    int number, f_num, s_num, t_num;
    clrscr();
    for (number = 1; number <= 500; number++) { // loop to check upto 500
      f_num = number / 100;
      s_num = (number % 100) / 10;
      t_num = (number % 100) % 10;
      if (((f_num * f_num * f_num) + (s_num * s_num * s_num) + (t_num * t_num * t_num)) == number) // condition to check if   armstrong number
        printf("%d\n", number);
    }
    getch();
  }


faltutech

Pursuing MCA from YMCA University, Faridabad

Leave a Reply

Your email address will not be published. Required fields are marked *

Read previous post:
Get Free Remote Desktop (RDP) Trick faltutech.club
Get Free Remote Desktop (RDP) Trick

UPDATE: Bluehost Has started charging for their cloud. So below trick may not work now. Note : linux only. First...

Close