Answers for "armstrong numbers"

2

armstrong numbers

int main(){
    
    int a;
    cin >> a;
    int check = a;
    int sum = 0;
    while(a!=0){
        int rem = a%10;
        sum += pow(rem,3);  //include cmath
        a/=10;
    }

    if(sum==check){
        cout << "armstrong";
    } else {
        cout << "not armstrong";
    }
    return 0;
}
Posted by: Guest on August-19-2021
3

armstrong number

sum of cubes of the digits
Posted by: Guest on November-02-2020
2

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;
Posted by: Guest on January-09-2021
1

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.");
    }
}
Posted by: Guest on August-26-2020
0

Armstrong numbers

Numbers -- Armstrong numbers
Write a method that can check if a number is Armstrong  number
 
Solution:
public  static  boolean ArmStrongNumber (int  num) {
int a = 0,    b =0,    c= num;
while(num>0){
              a=num%10; 
              num/=10; 
              b=b+(a*a*a);
}
 
if(c==b) {
return true;
}
return false;
}
Posted by: Guest on September-29-2021
1

armstrong numbers

// Armstrong Numbers
1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748...
Posted by: Guest on June-13-2021
2

armstrong numbers

int main(){
    
    int a;
    cin >> a;
    int check = a;
    int sum = 0;
    while(a!=0){
        int rem = a%10;
        sum += pow(rem,3);  //include cmath
        a/=10;
    }

    if(sum==check){
        cout << "armstrong";
    } else {
        cout << "not armstrong";
    }
    return 0;
}
Posted by: Guest on August-19-2021
3

armstrong number

sum of cubes of the digits
Posted by: Guest on November-02-2020
2

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;
Posted by: Guest on January-09-2021
1

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.");
    }
}
Posted by: Guest on August-26-2020
0

Armstrong numbers

Numbers -- Armstrong numbers
Write a method that can check if a number is Armstrong  number
 
Solution:
public  static  boolean ArmStrongNumber (int  num) {
int a = 0,    b =0,    c= num;
while(num>0){
              a=num%10; 
              num/=10; 
              b=b+(a*a*a);
}
 
if(c==b) {
return true;
}
return false;
}
Posted by: Guest on September-29-2021
1

armstrong numbers

// Armstrong Numbers
1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748...
Posted by: Guest on June-13-2021

Browse Popular Code Answers by Language