armstrong number
temp=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(temp==sum)
printf("armstrong number ");
else
printf("not armstrong number");
return 0;
armstrong number
temp=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(temp==sum)
printf("armstrong number ");
else
printf("not armstrong number");
return 0;
armstrong number in c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int cube(int a)
{
int c;
c = a*a*a;
return c;
}
int armnum(int *a)
{
int x = *a, n = 0, rem, r = 0;
while (x != 0) {
x /= 10;
n++;
}
x = *a;
while (x != 0) {
rem = x % 10;
r += cube(rem);
x /= 10;
}
if(r == *a){
return 1;
}
}
int main()
{
int a, y;
scanf("%d", &a);
y = armnum(&a);
if(y == 1){
printf("It is an Armstrong number.");
}
else{
printf("It is not an Armstrong number.");
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us