Armstrong Number In C

Introduction
  • In this blog, I am going to explain Armstrong number. It is nothing but "An Armstrong number of the three digits is an integer, such that the sum of the cubes of its digits is equal to the number itself ". 
Software Requirement
  • Turbo C++ OR C. 
Programming
  1. #include < stdio.h >   
  2. #include < stdlib.h > int main()  
  3. {  
  4.     int a, n, b = 0, t;  
  5.     printf("Enter the no:");  
  6.     scanf("%d", & n);  
  7.     t = n;  
  8.     while (n > 0)  
  9.     {  
  10.         a = n % 10;  
  11.         b = b + a * a * a;  
  12.         n = n / 10;  
  13.     }  
  14.     if (b == t)  
  15.     {  
  16.         printf("its an armstrong number");  
  17.     } else  
  18.     {  
  19.         printf("its not an armstrong number");  
  20.     }  
  21.     getch();  
  22.     return 0;  
  23. }   
Explanation
  • In the programming, given above, it is clearly understood that Armstrong number is a number which is equal to the sum of the digits, raised to the power and the total number of the digits in the number.

     programming

    programming 
Output

Output
 
Conclusion
  • Thus the Armstrong  number is clearly explained and executed successfully.
Next Recommended Reading Find The GCD Of Any Two Numbers