Step1: start
Step2: read the number
Step3: while n!=0 calculate sum+pow(n%10,3);
Else
Goto 5
Step4: n=n/10 goto 3
Step5: if sum==n print the no is armstrong else goto 6
Step6: print the no is not prime
Step7: stop
Program:
/* Program to find Armstrong number */
#include<stdio.h>
#include<conio.h>
main()
{
int n,sum=0,temp,r;
clrscr();
printf("\n\tProgram to find Armstrong number");
printf("\nEnter the number : ");
scanf("%d",&n);
while(n!=0)
{
r=n%10;
sum+=pow(r,3);
n=n/10;
}
if(sum==n)
printf("\nThe no is Armstrong");
else
printf("\nThe no is not Armstrong");
getch();
}
Output:
Program to find Armstrong number
Enter the number : 234
The no is not Armstrong
Program to find Armstrong number
Enter the number : 153
The no is Armstrong
3 comments: