Created
December 24, 2014 07:30
-
-
Save scratchyourbrain/1cdfa469945c93bccb99 to your computer and use it in GitHub Desktop.
C Program to Display Armstrong Number Between Two Intervals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int n1, n2, i, temp, num, rem; | |
printf("Enter two numbers(intervals): "); | |
scanf("%d %d", &n1, &n2); | |
printf("Armstrong numbers between %d an %d are: ", n1, n2); | |
for(i=n1+1; i<n2; ++i) | |
{ | |
temp=i; | |
num=0; | |
while(temp!=0) | |
{ | |
rem=(temp%10); | |
num+=rem*rem*rem; | |
temp/=10; | |
} | |
if(i==num) | |
{ | |
printf("%d ",i); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output plss