Menus

Tuesday, 31 March 2020

To check given number is armstrong number or not



#include<stdio.h>

void main()
{

int n,m,b=0,a;

printf("Enter the number ");
scanf("%d",&n);

m=n;

while(n>0)
{

a=n%10;
n=n/10;
b=b+(a*a*a);

}

if(m==b)
  printf("%d is amstrong\n",m);
else
  printf("%d is not amstrong\n",m);


}






No comments:

Post a Comment