Headlines
Loading...
C Program to check whether the number is Armstrong no or not

C Program to check whether the number is Armstrong no or not

C Program to check whether the number is Armstrong no or not

#include<stdio .h="">
#include<conio .h="">
#include<math .h="">
void main()
{
int num,a,p,count=0,s=0,b,c;
clrscr();
printf("Enter the number\n");
scanf("%d",&amp;num);
b=num;
p=num;
while(num!=0)
{
a=num%10;
count++;
num=num/10;
}
while(b!=0)
{
c=b%10;
b=b/10;
s=s+pow(c,count);
}
printf("\nNo of digits:%d",count);
printf("\nPower of number of digits:%d",s);
if(s==p)
printf("\nArmstrong number");
else
printf("\nNot an armstrong number");
getch();
}




****************OUTPUT*************
Enter the number
153

No of digits:3
Power of number of digits:153
Armstrong number</math></conio></stdio>
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***