Programming Code Center(PCC)
[CPP]

(PCC)::[How-to-write-CPP-Program-to-Display-Armstrong-Number-Between-Two-Intervals]::[cpp]

File Name : Armstrong_Number_Between_Two_Intervals.cpp

//Example: Display Armstrong Number Between Intervals
#include <iostream>
using namespace std;

int main()
{
  int num1, num2, i, num, digit, sum;

  cout << "Enter first number: ";
  cin >> num1;

  cout << "Enter second number: ";
  cin >> num2;

  cout << "Armstrong numbers between " << num1 << " and " << num2 << " are: " << endl;
  for(i = num1; i <= num2; i++)
  {
        sum = 0;
        num = i;

        for(; num > 0; num /= 10)
        {
            digit = num % 10;
            sum = sum + digit * digit * digit;
        }

        if(sum == i)
        {
            cout << i << endl;
        }
  }

  return 0;
}

Output :

Armstrong_Number_Between_Two_Intervals.jpg