From cf782a5bcc52cc6d4c80199f80952ea7fc6f6f6d Mon Sep 17 00:00:00 2001 From: Karan143246 <103922464+Karan143246@users.noreply.github.com> Date: Sat, 8 Oct 2022 20:42:17 +0530 Subject: [PATCH] Uploaded Armstrong.cpp Added a C++ Program to check whether the entered number is armstrong or not . --- Easy/Armstrong.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Easy/Armstrong.cpp diff --git a/Easy/Armstrong.cpp b/Easy/Armstrong.cpp new file mode 100644 index 0000000..f67445b --- /dev/null +++ b/Easy/Armstrong.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; + +int main() { + int num, originalNum, remainder, result = 0; + cout << "Enter a three-digit integer: "; + cin >> num; + originalNum = num; + + while (originalNum != 0) { + // remainder contains the last digit + remainder = originalNum % 10; + + result += remainder * remainder * remainder; + + // removing last digit from the orignal number + originalNum /= 10; + } + + if (result == num) + cout << num << " is an Armstrong number."; + else + cout << num << " is not an Armstrong number."; + + return 0; +} \ No newline at end of file