Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program to display Armstrong number between intervals added. #194

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
33 changes: 33 additions & 0 deletions CPP/Display Armstrong Number Between Intervals.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#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;
}