BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

C++ Program to display Armstrong Numbers between 1 and 1000

Last Updated: September 7, 2017 by Chaitanya Singh | Filed Under: C++ Programs

An integer number is known as Armstrong number if the sum of cubes of its individual digits is equal to the number itself. Here we will write a program to display armstrong numbers upto 1000, if you are looking for a program to check armstrong number then refer: C++ program to check whether input number is armstrong or not.

Example: Prints Armstrong numbers upto 1000

This program prints the armstrong numbers between 1 and 100. To understand this program you should have the knowledge of nested for loop.

#include <cmath>
using namespace std;
int main(){
   int sum, num;
   cout<<"Armstrong numbers between 1 and 1000: ";
   for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
         for(int k = 0; k < 10; k++) {
            num = i * 100 + j * 10 + k;
            sum = pow(i, 3) + pow(j, 3) + pow(k, 3);
            if(num == sum)
               cout<<num<<"  ";
         }
      }
   }
   return 0;
}

Output:

Armstrong numbers between 1 and 1000: 0  1  153  370  371  407

Top Related Articles:

  1. C++ Program to check Armstrong Number
  2. C++ Program to check whether the input number is Even or Odd
  3. C++ Program to Check Armstrong Number using user-defined function
  4. C++ Program to find the sum of n natural numbers
  5. C++ Program to Display the Number Entered by User

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

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

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap