C++

An Armstrong Numbers Between 1 And 1000 Display Program In C++

If the product of the squares of each of an integer number’s digits equals the number itself, the number is said to be an Armstrong number. If you’re looking for a program to verify armstrong numbers, check out this C++ program to see if the input number is armstrong or not. We’ll be writing a program here to show armstrong numbers up to 1000.

Prints Armstrong numbers up to 1000, for instance.

The armstrong numbers between 1 and 100 are printed by this application. It is necessary to be familiar with nested for loops in order to comprehend this program.

#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

Related Articles

Leave a Reply

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

Back to top button