Monday, September 18, 2017

17)WAP to enter any number and check it is armstrong No or not. in CPP



Program




#include

#include

class armstrong

{

int n,no,r,c;

public:

palindrom()

{ r=0;

}

void getdata()

{
cout<<"\n\t\t Enter Number:";

cin>>no;

}

void putdata()

{ c=no;

for( ;no>=1; )

{

n=no%10;

r=r+(n*n*n);

no=no/10;

}

if(c==r)

{

cout<<"\n\t\t A Number Is Armstrong !!";


}

else

{

cout<<"\n\t\t A Number Not Armstrong !!";

}

}

};

void main()

{

clrscr();

armstrong p1;

p1.getdata();

p1.putdata();

getch();

}


-------------------------------Output---------------------------



Enter Number:153

A Number Is Armstrong !!



No comments:

Post a Comment