mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-08 21:16:26 +08:00
rename Dynamic Programming -> dynamic_programming (#645)
* rename Dynamic Programming -> dynamic_programming * rename dynamic-programming -> dynamic_programming
This commit is contained in:
20
dynamic_programming/Armstrong Number.cpp
Normal file
20
dynamic_programming/Armstrong Number.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
//program to check whether a number is an armstrong number or not
|
||||
#include <iostream.h>
|
||||
#include <Math.h>
|
||||
int main()
|
||||
{
|
||||
int n, k, d, s = 0;
|
||||
cout << "Enter a number:";
|
||||
cin >> n;
|
||||
k = n;
|
||||
while (k != 0)
|
||||
{
|
||||
d = k % 10;
|
||||
s += (int)pow(d, 3);
|
||||
k /= 10;
|
||||
}
|
||||
if (s == n)
|
||||
cout << n << "is an armstrong number";
|
||||
else
|
||||
cout << n << "is not an armstrong number";
|
||||
}
|
||||
Reference in New Issue
Block a user