Created
December 24, 2014 07:05
-
-
Save scratchyourbrain/0571336445479a6fe1e9 to your computer and use it in GitHub Desktop.
C program to Check Armstrong Number
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 n, n1, rem, num=0; | |
printf("Enter a positive integer: "); | |
scanf("%d", &n); | |
n1=n; | |
while(n1!=0) | |
{ | |
rem=n1%10; | |
num+=rem*rem*rem; | |
n1/=10; | |
} | |
if(num==n) | |
printf("%d is an Armstrong number.",n); | |
else | |
printf("%d is not an Armstrong number.",n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need a C program for armstrong no for 4 digits