C Program To Know Weather a Number is Armstrong or not

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,m,j,i,arm=0,digits=0;
clrscr();
printf("Enter number: ");
scanf("%d",&n);
j=m=n;
while(j>0)
{
j=j/10;
digits++;
}
 while(m>0)
 {
 i=m%10;
 arm=arm+pow(i,digits);
 m=m/10;
 }
  if(arm==n)
  printf("\nArmstrong");
  else
  printf("Not Armstrong");

getch();
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment