Skip to content

Commit ddfb7af

Browse files
Armstrong number
1 parent 4307d00 commit ddfb7af

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Armstrong No/armstrongnum.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include<stdio.h>
2+
#include<math.h>
3+
4+
int main()
5+
{
6+
int i, temp,num,count=0,sum=0;
7+
8+
scanf("%d",&num);
9+
10+
temp=num;
11+
while(temp!=0)
12+
{
13+
count++;
14+
temp=temp/10;
15+
}
16+
temp=num;
17+
while(temp!=0)
18+
{
19+
sum=sum + pow(temp%10,count);
20+
temp=temp/10;
21+
}
22+
printf("%d",sum);
23+
24+
//and if sum is equal to num then that no is said to be Armstrong number.TRy 371
25+
return 0;
26+
}

0 commit comments

Comments
 (0)