Google Ads

Wednesday, May 27, 2009

Armstrong Number

ARMSTRONG NUMBER

#include”stdio.h”

#include “conio.h”

void main()

{

int f,r,s,n;

clrscr();

printf("\nEnter the Number : ");

scanf("%d",&n);

s=0;

f=n;

while(n>0)

{

r=n%10;

s=s+(r*r*r);

n=n/10;

}

if(f==s)

{

printf("\n\nThe given no %d is an armstrong number",f);

}

else

{

printf("\n\nThe given no %d is not an armstrong number",f);

}

getch();

}

Output will be


Enter the Number : 153

The given no 153 is an armstrong number

Enter the Number : 156

The given no 156 is not an armstrong number

No comments:

Post a Comment