Thursday, 19 December 2019

Armstrong number in C

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int n,num,r,c=0,s=0;
printf("Enter the number: ");
scanf("%d",&n);
num=n;
while(num>0)
{
r=num%10;
c++;
num=num/10;
}
num=n;
while(num>0)
{
r=num%10;
s=s+pow(r,c);
num=num/10;
}
if(s==n)
printf("The number %d is Armstrong Number..",n);
else
printf("The number %d is  NOT Armstrong Number..",n);
getch();
return 0;
}

No comments:

Post a Comment

Convey your thoughts to authors.