Wednesday, July 20, 2011

Program to check armstrong no. of any digit {Version 1}

/*Serial No.69     [swami42.cpp]*/

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,num,m,sum,dig,p,n;
clrscr();
sum=0;
printf("Enter the number=");
scanf("%d",&n);
num=n;
printf("Enter the no. of digits in the given no.=");
scanf("%d",&p);
for(i=1;i<=p;i++)
{dig=n%10;
n=n/10;
sum=pow(dig,p)+sum;
 }
if(num==sum)
printf("\nArmstrong no.");
else
printf("\n Not Armstrong no.");
getch();
}

No comments:

Post a Comment

If you have any doubt, feel free to ask...