Created
January 19, 2019 18:02
-
-
Save uysalserkan/855a291d6634a6c28c4acf4c19e3f3ad to your computer and use it in GitHub Desktop.
The program find the armstrong numbers between 100 to 999
This file contains hidden or 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 <iostream> | |
using namespace std; | |
void armstrong(int num); | |
int main(void){ | |
int i; | |
for(i=100;i<999;i++) | |
armstrong(i); | |
} | |
void armstrong(int num){ | |
int temp; | |
temp=num; | |
int i,j,k; | |
i=temp%10; | |
temp /=10; | |
j=temp%10; | |
temp /=10; | |
k=temp%10; | |
i=i*i*i; | |
j=j*j*j; | |
k=k*k*k; | |
if(i+j+k==num) | |
cout <<num<<" is armstrong number!"<<endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment