Home » NO IDEA » Armstrong Number

Armstrong Number

Blog Stats

  • 14,863 hits
December 2012
M T W T F S S
« Sep   Jan »
 12
3456789
10111213141516
17181920212223
24252627282930
31  
 

Armstrong Number

//To check whether the given number is Armstrong number or not #include<stdio.h> int main() { int num,temp; int sum=0,r; printf("\n Enter the Number"); scanf("%d",&num); temp=num; while(num>0) { r=num%10; sum=sum+(r*r*r); num=num/10; } if(sum==temp) { printf("\n It is an amstrong number"); } else { printf("\n It is not an amstrong number"); } return 0; }

//Generation of the Armstrong Number

#include<stdio.h> int main() { int range,i,temp,num; int sum=0,r; printf("\n Enter the Range"); scanf("%d",&range); printf("\n The list of Armstrong NUmbers\n"); for(i=1;i<range;i++) { num=i; temp=num; sum=0; while(num>0) { r=num%10; sum=sum+(r*r*r); num=num/10; } if(sum==temp) { printf("\n\t %d",sum); } }

Screenshot at 2012-12-22 23:30:09
return 0;
}

Advertisements

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: