#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,m=0,x,y;
clrscr();
printf("\n Enter a three digit numnber : ");
scanf("%d",&n);
y=n;
while(n!=0)
{
x=n%10;
m+=pow(x,3);
n=n/10;
}
if(y==m)
printf("\n The given number is an Armstrong number");
else
printf("\n The given number is not an Armstrong number");
getch();
}
Output

#include<conio.h>
#include<math.h>
void main()
{
int n,m=0,x,y;
clrscr();
printf("\n Enter a three digit numnber : ");
scanf("%d",&n);
y=n;
while(n!=0)
{
x=n%10;
m+=pow(x,3);
n=n/10;
}
if(y==m)
printf("\n The given number is an Armstrong number");
else
printf("\n The given number is not an Armstrong number");
getch();
}
Output
No comments:
Post a Comment