int main(){ int num,r,sum,temp; int min,max; printf("Enter […] Check the given number is armstrong number or not using c program" />

# Check the given number is armstrong number or not using c program

Levels of difficulty: / perform operation:

# Program 1

```#include<stdio.h>
int main(){
int num,r,sum=0,temp;

printf("Enter a number: ");
scanf("%d",&num);

temp=num;
while(num!=0){
r=num%10;
num=num/10;
sum=sum+(r*r*r);
}
if(sum==temp)
printf("%d is an Armstrong number",temp);
else
printf("%d is not an Armstrong number",temp);

return 0;
}
```

# Result 1

```Enter a number: 153
153 is an Armstrong number
```

# Program 2

```#include<stdio.h>
int main(){
int num,r,sum,temp;
int min,max;

printf("Enter the minimum range: ");
scanf("%d",&min);

printf("Enter the maximum range: ");
scanf("%d",&max);

printf("Armstrong numbers in given range are: ");
for(num=min;num<=max;num++){
temp=num;
sum = 0;

while(temp!=0){
r=temp%10;
temp=temp/10;
sum=sum+(r*r*r);
}
if(sum==num)
printf("%d ",num);
}

return 0;
}
```

# Result 2

```Enter the minimum range: 1
Enter the maximum range: 200
Armstrong numbers in given range are: 1 153
```

# Program 3

```#include<stdio.h>
int main(){
int num,r,sum=0,temp;

printf("Enter a number: ");
scanf("%d",&num);

for(temp=num;num!=0;num=num/10){
r=num%10;
sum=sum+(r*r*r);
}
if(sum==temp)
printf("%d is an Armstrong number",temp);
else
printf("%d is not an Armstrong number",temp);

return 0;
}
```

# Result 3

```Enter a number: 370
370 is an Armstrong number
Logic of Armstrong number in c
```

# Program 4

```#include<stdio.h>
int main(){
int num,r,sum,temp;

for(num=1;num<=500;num++){
temp=num;
sum = 0;

while(temp!=0){
r=temp%10;
temp=temp/10;
sum=sum+(r*r*r);
}
if(sum==num)
printf("%d ",num);
}

return 0;
}
```

# Result 4

```1 153 370 371 407
```