===========================================================================
CODING
#include<iostream.h>
#include<conio.h>
#include<math.h>
int Armstrong(int);
void main()
{
clrscr();
int n,i;
cout<<"Enter Number To Check for Armstrong Number: ";
cin>>n;
i=Armstrong(n);
if(i==0)
cout<<"\n\nThe Number is a Armstrong!!";
else
cout<<"\n\nThe Number is NOT a Armstrong Number";
getch();
}
int Armstrong(int a)
{
int i,m;
for(i=0,m=a;m>0;)
{
i=i+pow(m%10,3);
m/=10;
}
if(a==i)
return 0;
else
return 1;
}
CODING
#include<iostream.h>
#include<conio.h>
#include<math.h>
int Armstrong(int);
void main()
{
clrscr();
int n,i;
cout<<"Enter Number To Check for Armstrong Number: ";
cin>>n;
i=Armstrong(n);
if(i==0)
cout<<"\n\nThe Number is a Armstrong!!";
else
cout<<"\n\nThe Number is NOT a Armstrong Number";
getch();
}
int Armstrong(int a)
{
int i,m;
for(i=0,m=a;m>0;)
{
i=i+pow(m%10,3);
m/=10;
}
if(a==i)
return 0;
else
return 1;
}
===========================================================================
No comments:
Post a Comment