Non-Recursive C Program:
Aim:To find given number is Armstrong Number or Not.
Program:
#include<stdio.h>
void main()
{
int num,num1,arms=0,rem;
printf("Enter the number:\n"); scanf("%d",&num);
num1=num;
while(num1>0)
{
rem=num%10; arms=arms+(rem*rem*rem); num1=num1/10;
}
if(num==arms)
printf(" \n%d is an Armstrong number ",num);
else
printf("\n%d is NOT an Armstrong number",num);
}
Output:
Enter the Number: 121
121 is NOT an Armstrong number
Click Here to view programs list
No comments:
Post a Comment