From 160b82e9e08d42073dd8e75b83ff7e571b9cc5c9 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Wed, 13 Oct 2021 16:45:16 +0000 Subject: [PATCH] clang-format and clang-tidy fixes for 243dcc15 --- dynamic_programming/armstrong_number.cpp | 26 +++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/dynamic_programming/armstrong_number.cpp b/dynamic_programming/armstrong_number.cpp index ba8f054dd..53f1be9fe 100644 --- a/dynamic_programming/armstrong_number.cpp +++ b/dynamic_programming/armstrong_number.cpp @@ -1,6 +1,6 @@ // Program to check whether a number is an armstrong number or not -#include #include +#include using std::cin; using std::cout; @@ -8,34 +8,32 @@ int main() { int n = 0, temp = 0, rem = 0, count = 0, sum = 0; cout << "Enter a number: "; cin >> n; - + temp = n; - + /* First Count the number of digits in the given number */ - while(temp != 0) { + while (temp != 0) { temp /= 10; count++; } - /* Calaculation for checking of armstrongs number i.e. + /* Calaculation for checking of armstrongs number i.e. in a n digit number sum of the digits raised to a power of n is equal to the original number */ - + temp = n; - while(temp!=0) { - rem = temp%10; - sum += (int) pow(rem,count); - temp/=10; + while (temp != 0) { + rem = temp % 10; + sum += static_cast(pow(rem, count)); + temp /= 10; } - if (sum == n) { cout << n << " is an armstrong number"; - } - else { + } else { cout << n << " is not an armstrong number"; } - + return 0; }