From c37ae55dd43bd6b8f17c5ef4f068aa305f57bbe0 Mon Sep 17 00:00:00 2001 From: jkunal14 <43882559+jkunal14@users.noreply.github.com> Date: Sat, 6 Oct 2018 22:50:51 +0530 Subject: [PATCH] Update Armstrong.cpp --- C++/Armstrong.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/C++/Armstrong.cpp b/C++/Armstrong.cpp index acba399f3..af0099f94 100644 --- a/C++/Armstrong.cpp +++ b/C++/Armstrong.cpp @@ -1,25 +1,26 @@ #include - using namespace std; int main() { -int arm=0,a,b,c,d,no; -cout << "Enter any number" << endl; -cin >> no; -d = no; -while( no > 0){ - a=no%10; - no=no/10; - arm=arm+a*a*a; -} -if(arm==d){ - cout<<"Yes"; -} -else{ - cout<<"No"; - -} - -return 0; + int num,n,digit,sum=0; + cout<<"Enter any positive number "<>num; + n=num; + + while(num !=0) + { + digit=num%10; + sum+=digit*digit*digit; + num/=10; + } + if(sum==n) + { + cout<<"The entered by you is an Armstrong Number "<