-->

hseb_12_sol:Program to know a number is Armstrong or not

/*program to check a number is Armstrong or not .
we are taking number with three digits*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int i,k,rem,sum=0;
printf("enter a three digit number to be checked\n");
scanf("%d",&i);
k=i;
while(i!=0)
{
     rem=i%10;
    sum=sum+pow(rem,3);
    i=i/10;
  }
 if(sum==k)
 {
       printf("%d is Armstrong\n",k);

 }
else
{
printf("%d is not Armstrong\n",k);;}
getch();
}

No comments:

Post a Comment