F Write a program to find the given number is Armstrong Number or not | CodeTheta

Write a program to find the given number is Armstrong Number or not

January 18, 2014

/* Armstrong Number */

/* http://native-code.blogspot.com */
#include<stdio.h>
#include<conio.h>

void main()
{
 int x,y,z,s=0;
 printf("/* http://native-code.blogspot.com */\n\n\n\t Enter a positive number as you wish...");
 scanf("%d",&x);
 y=x;

 while(x>0)
 {
  z=x%10;
  s=s+(z*z*z);
  x=x/10;
 }

 if(s==y)
 printf("\n\n\t Armstrong Number !!!");
 else
 printf("\n\n\t Not a Armstrong Number !!!");
 getch();
}
/* http://native-code.blogspot.com */

Post a Comment