Tuesday, February 28, 2017

(14)Write a program to enter any No. and display reverse No. in CPP (Using Class)

vProgram
#include<iostream.h>
#include<conio.h>
class reverse
{
  int n,no,r;
  public:
    reverse()
    { r=0;
    }
    void getdata()
    {
     cout<<"\n\t\t Enter Number:";
    cin>>no;
    }
    void putdata()
    {
      while(no>=1)
      {
       n=no%10;
       r=(r*10)+n;
       no=no/10;
      }
      cout<<"\n\t\t A reverse Number Is:"<<r;
     }
  };
  void main()
  {
   clrscr();
   reverse r1;
   r1.getdata();
   r1.putdata();
   getch();
 }
vOutput

Enter Number:123
A reverse Number Is:321

No comments:

Post a Comment