Infolinks - Earn Easy Money

Saturday, April 4, 2015

C++ program to find Armstrong numbers

#include <iostream>
#include <conio.h>
#include <stdio.h>
using namespace std;
int main (  )
{
int a,b,c,d,e,f,res,num=1 ;
printf(" Armstrong Numbers from 1 to 500 \n") ;
while ( num <= 500 )
{
a = num % 10 ;
b = num / 10 ;
c = b % 10 ;
d = num / 10 ;
e = d % 10 ;
f = d / 10 ;
if ( num == (a*a*a) + (c*c*c) + (e*e*e) )
{
printf ( "\n %d ", num ) ;
}
num++ ;
}
return 0 ;
}

No comments:

Post a Comment

Must drop your comments about post.