Friday, 21 June 2013

Armstrong number (Entered no. is armstrong or not)

/* compiler- Turbo c++ author- Mangilal Sharma =================================*/ 
#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
 int n,a,b,arm=0;
 clrscr();
 printf("Enter a number: ");
 scanf("%d",&n);
 b=n;
 while(n>0)
 {
  a=n%10;
  n=n/10;
  arm=arm+pow(a,3);
 }
 printf("Entered digit's sum of the cubes is: %d\n",arm);
 if(arm==b)
 printf("Entered no. is armstrong");
 else
 printf("Entered no. is not armstrong");
 getch();
}
/*=============================19Nov.,2010=============================*/

No comments:

Post a Comment

You are welcome, your comment helps me to make this blog more better.