We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a94254 commit fa131b3Copy full SHA for fa131b3
C/Armstrong.c
@@ -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