C++ Program To Illustrate The Concept Of Class and Object.

#include<iostream.h> 
#include<conio.h> 
class student 
{ 
      private: 
                   int rn; 
                   float fees; 
      public: 
                   void readdata() 
               { 
                       cout<<"Enter the rollno. and fees of the student"; 
                       cin>>rn>>fees; 
               } 
                  void writedata() 
              { 
                    cout<<"The rollno. is "<<rn<<endl; 
                    cout<<" The fees is "<<fees<<endl; 
              } 
}; 
          void main() 
      { 
           clrscr(); 
           student st; 
           st.readdata(); 
           st.writedata(); 
           getch(); 
      } 

Expected Output:
Enter the rollno. and fees of the student
25
500
The rollno. is 25
The fees is 500

Post a Comment

Previous Post Next Post