1: #include<iostream.h>
2: #include<conio.h>
3: class Armstrong{
4: int num;
5: public:
6: void input()
7: {
8: cout<<"Enter the Number:"<<endl;
9: cin>>num;
10: }
11: void findArmstrong();
12: };
13: void Armstrong::findArmstrong()
14: {
15: int rem,temp,rev=0;
16: temp=num;
17: while(temp>0)
18: {
19: rem=temp%10;
20: rev=rev + rem*rem*rem;
21: temp=temp/10;
22: }
23: if(num==rev)
24: {
25: cout<<"Armstrong Number";
26: }
27: else
28: {
29: cout<<"Not Armstrong Number";
30: }
31: }
32: void main()
33: {
34: clrscr();
35: Armstrong arms;
36: arms.input();
37: arms.findArmstrong();
38: getch();
39: }
This blog aims at helping you learn C,C++ and Java programming languages and thus enabling you to use its immense possibilities in the computing world.
Program to find whether a given number is Armstrong in C++ using Class
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
leave a comment here