Sunday, 11 September 2016

Armstrong Number II

C++ PROGRAMS

The following program gives you all the 3 digit numbers which are Armstrong Numbers.

In this I will use for loop and if statement.

Code:

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,i;
cout<<"3-Digit Armstrong Numbers"<<"\n";

for(i=100;i<=999;i++)
{
 a=i%10;
 b=i/10;
 b=b%10;
 c=1/100;
 a=a*a*a;
 b=b*b*b;
 c=c*c*c;
 if(i!=a+b+c)
 continue; 
 cout<<i<<"\n";
}

getch();


Output:


  


For determining whether any 3-digit number entered by the user is an Armstrong number or not please go through Armstrong Number I .



For any queries or suggestions please comment !





No comments:

Post a Comment