Skip to content

Commit fa131b3

Browse files
authored
Create Armstrong.c (#69)
1 parent 3a94254 commit fa131b3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

C/Armstrong.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Check if a number is Armstrong number or not
2+
3+
#include<stdio.h>
4+
5+
int isArmstrong(int n){
6+
int r,sum=0,temp;
7+
temp=n;
8+
while(n>0){
9+
r=n%10;
10+
sum=sum+(r*r*r);
11+
n/=10;
12+
}
13+
14+
if(temp==sum){
15+
return 1;
16+
}
17+
return 0;
18+
}
19+
20+
int main(){
21+
int n;
22+
printf("Enter a number\n");
23+
scanf("%d",&n);
24+
int result = isArmstrong(n);
25+
printf("%d",result);
26+
}

0 commit comments

Comments
 (0)