-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArmstrong.cpp
More file actions
45 lines (34 loc) · 895 Bytes
/
Armstrong.cpp
File metadata and controls
45 lines (34 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Armstrong Number - An Armstrong Number of three digits is an integer such
that the sum of the cubes its digits is equal to the number itself.
Print TRUE if it is otherwise FALSE
*/
#include "iostream"
// #include "conio.h" Do not use conio.h NON-STANDARD HEADER FILE
// format/indent your code properly
using namespace std;
int main() // In C++ main should always return a value.
{
// clrscr(); NON-STANDARD FUNCTION
long num;
void isarms(long); //Explain this statement
cout << "Enter a number:"<<endl; // endl is used for newline.
cin >> num;
isarms(num);
// getch(); NON-STANDARD FUNCTION
return 0;
}
void isarms(long num)
{
long a = num, sum = 0, x;
while(a)
{
x = a % 10;
sum = sum + (x * x * x);
a /= 10;
}
if(sum == num)
cout << "TRUE";
else
cout << "FALSE";
}