#include< stdio.h >
#include< conio.h >
void main()
{
int sum=0,digit,n,temp;
clrscr();
printf("Enter a number:");
scanf("%d",&n);
temp=n;
while(n!=0)
{
digit=n%10;
sum=sum+digit*digit*digit;
n=n/10;
}
if(sum==temp)
{
printf("The number %d is an Armstrong Number",n);
}
else
{
printf("The number %d is not an Armstrong Number",n);
}
getch();
}
OUTPUT :
Enter a number :153
The number 153 is an Armstrong Number
OR
OUTPUT :
Enter a number :152
The number 152 is not an Armstrong Number
#include< conio.h >
void main()
{
int sum=0,digit,n,temp;
clrscr();
printf("Enter a number:");
scanf("%d",&n);
temp=n;
while(n!=0)
{
digit=n%10;
sum=sum+digit*digit*digit;
n=n/10;
}
if(sum==temp)
{
printf("The number %d is an Armstrong Number",n);
}
else
{
printf("The number %d is not an Armstrong Number",n);
}
getch();
}
OUTPUT :
Enter a number :153
The number 153 is an Armstrong Number
OR
OUTPUT :
Enter a number :152
The number 152 is not an Armstrong Number
No comments :
Post a Comment