Make a new start with a new Thought!

NOTE :                // indicates comments.This wont get printed in the output.This is used for for documentation purpose. PROGRAM: #...

ARMSTRONG NUMBER

NOTE :
              
// indicates comments.This wont get printed in the output.This is used for for documentation purpose.

PROGRAM:

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
  int num,n=0,rem,result=0,temp;
  clrscr();
  printf("Please enter a number\n");
  scanf("%d",&num);
  temp=num;
 while(temp!=0)
 {
   temp=temp/10;
   n++;
  }
  temp=num;
  while(temp!=0)
   {
    rem=temp%10;
    result= result+ pow(rem,n);
    temp=temp/10;
   }
   if(result==num)
   { 
    printf("The Given number is armstrong");
   }
   else
   {
     printf("The given number is not armstrong");
   }
getch();
}


OUTPUT :


0 comments: