Computer Science, asked by dishant4, 1 year ago

wap to input a no. and check whether a no. is a Armstrong

no.

Answers

Answered by siddhartharao77
1
   int a, b, c, d;
    c = 0;

    printf("Enter a number");   

    scanf("%d",&a);

    b =  a;   

   while(b!=0)
      {     
   d = b%10;     
  c = c + d*d*d;     
  b = b / 10;   
 }   

    if(a==c) 

     printf("Armstrong");

    else 

   printf("Not Armstrong ");   

return 1;

}
Answered by lenovoideapadanishka
2

hope it helps you!!!

please mark me as the brainliest ^_^

import java.util.*;

class armstrong  

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

int s=0,d,di;

System.out.println("enter a no.");

int n=sc.nextInt();

int x=n;

while(x!=0)

{

d=x%10;

di=d*d*d;

s=s+di;

x=x/10;

}

if(s==n)

System.out.println("armstrong");

else

System.out.println("not armstrong");

}

}

Similar questions