Monday, 19 October 2015

C program to check whether the no. is armstrong or not

#include<stdio.h>
#include<conio.h>
void main()
{
int y,x,r,sum=0;
clrscr();
printf("enter a no :");
scanf("%d",&y);
x=y;
while(x!=0)
{
r=x%10;
sum=sum+(r*r*r);
x=x/10;
}
if(y==sum)
printf("\n no is armstrong no");
else
printf("\n no is not armstrong");
getch();
}

No comments:

Post a Comment