PROGRAM TO CHECK WHETHER A GIVEN NUMBER IS ARMSTRONG OR NOT

/*PROGRAM TO CHECK WHETHER A GIVEN NUMBER IS ARMSTRONG OR NOT*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,temp,arm=0,rem;
clrscr();
printf(“Enter the number: “);
scanf(“%d”,&n);
temp=n;
while(temp!=0)
{
rem=temp%10;
temp=temp/10;
arm=arm+rem*rem*rem;
}
if(arm==n)
{
printf(“Number %d is an armstrong number”,n);
}
else
{
printf(“Number %d is not an armstromg number”,n);
}
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *