From 26b6217f70ab6267df220c8c9074a74c7664be75 Mon Sep 17 00:00:00 2001 From: itsABHIROOP <84619398+itsAbhirup@users.noreply.github.com> Date: Tue, 5 Oct 2021 22:46:43 +0530 Subject: [PATCH] Create armstrong.c --- armstrong.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 armstrong.c diff --git a/armstrong.c b/armstrong.c new file mode 100644 index 0000000..53c9879 --- /dev/null +++ b/armstrong.c @@ -0,0 +1,28 @@ +#include +#include +void main() +{ + int num,n,count=0,res=0; + printf("Enter an integer :: "); + scanf("%d",&num); + n=num; + while(n!=0) + { + n=n/10; + count++; + } + n=num; + while(n!=0) + { + res=res+pow(n%10,count); + n=n/10; + } + if(num==res) + { + printf("The given integer is armstrong\n"); + } + else + { + printf("The given integer is not armstrong\n"); + } +}