From e0416c06462032292dfe2e5881c51fd376ae3ffb Mon Sep 17 00:00:00 2001 From: TechyAyush <69710917+TechyAyush@users.noreply.github.com> Date: Sat, 24 Oct 2020 21:28:15 +0530 Subject: [PATCH] Update armStrongNumber.c Added separate function for getting it is Armstrong or not.And some comments updated.!! --- armStrongNumber.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/armStrongNumber.c b/armStrongNumber.c index 183e244..cd45802 100644 --- a/armStrongNumber.c +++ b/armStrongNumber.c @@ -1,21 +1,27 @@ -#include -/*The number which each number is cube is equal to orignial number then it's called armstrong number.*/ -int main() +#include +/*The number which each digit's cube is equal to orignial number then it's called armstrong number.*/ +void isArmstrong(int n) //Function for finding Armstrong { - int n,a,sum,rem; - printf("Enter the number to check where number is armstrong or not:"); - scanf("%d",&n); - a=n; - sum=0; - while(n>0) + int a, sum, rem; + a = n; + sum = 0; + while (n > 0) { - rem=n%10; - sum=sum+rem*rem*rem; - n=n/10; + rem = n % 10; + sum = sum + rem * rem * rem; + n = n / 10; } - if(sum==a) - printf("%d is armstrong number",a); + if (sum == a) + printf("%d is armstrong number", a); else - printf("%d is not armstrong number",a); + printf("%d is not armstrong number", a); +} +int main() +{ + int n; + printf("Enter the number to check where number is armstrong or not:"); + scanf("%d", &n); + isArmstrong(n);//calling function + return 0; }