mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-11-27 22:24:29 +08:00
formatting source-code for d7af6fdc8c
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
// Program to check whether a number is an armstrong number or not
|
||||
#include <iostream>
|
||||
|
||||
using std::cout;
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
|
||||
int main() {
|
||||
int n, k, d, s = 0;
|
||||
cout << "Enter a number:";
|
||||
cin >> n;
|
||||
k = n;
|
||||
while (k != 0) {
|
||||
d = k % 10;
|
||||
s += d * d * d;
|
||||
k /= 10;
|
||||
}
|
||||
if (s == n)
|
||||
cout << n << "is an armstrong number";
|
||||
else
|
||||
cout << n << "is not an armstrong number";
|
||||
int main()
|
||||
{
|
||||
int n, k, d, s = 0;
|
||||
cout << "Enter a number:";
|
||||
cin >> n;
|
||||
k = n;
|
||||
while (k != 0)
|
||||
{
|
||||
d = k % 10;
|
||||
s += d * d * d;
|
||||
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