Write a program in C++ to find the Armstrong number for a given range of number
- برمجة سي بلس بلس
- برمجة
- 2021-05-14
- MarwaMohammed
الأجوبة
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int num, r, sum, t, mm;
int sno, eno;
cout << "\n\n Find the Armstrong number for a given range of number:\n";
cout << "-----------------------------------------------------------\n";
cout << " Input starting number of range: ";
cin >> sno;
cout << " Input ending number of range: ";
cin >> eno;
cout << " Armstrong numbers in given range are: " << endl;
for (num = sno; num <= eno; num++)
{
t = num;
sum = 0;
while (t != 0)
{
r = t % 10;
mm = pow(r, 3);
sum = sum + mm;
t = t / 10;
}
if (sum == num)
cout << num << " ";
}
cout << endl;
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال