9 Jan 2015

Program:The given number is Armstrong or not



#include<stdio.h>
#include<conio.h>
void main()
{
int  n,r,m,arm=0;
clrscr();
printf("Enter the any given number:\n");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
arm=arm+r*r*r;
n=n/10;
}
if(m==arm)
printf("The given number is Armstrong\n");
else
printf("The given number is not Armstrong\n");
getch();
}

No comments:

Post a Comment