C PROGRAM |
WRITE A "C " PROGRAM TO FIND THE GIVEN NUMBER IS ARMSTRONG
OR NOT
#include <stdio.h>
#include<conio.h>
void main()
{
int n,temp,r,sum=0;
clrscr();
printf("enter the number \n");
scanf("%d",&n);
temp=n;
while(n!=0)
{
r=n%10;
sum+=(r*r*r);
n=n/10;
}
if(sum==temp)
{
printf ("the number is Armstrong number");
}
else
{
printf ("the number is not Armstrong number");
}
getch();
}
OUTPUT :
enter the number
153
the number is Armstrong number
[Process completed (code 10) - press Enter]
153
the number is Armstrong number
[Process completed (code 10) - press Enter]
No comments:
Post a Comment