English
Tamil Nadu Board of Secondary EducationHSC Science Class 11

Write the output of the following #include<iostream> using namespace std; class student { int rno, marks; public: student(int r,int m) { cout<<"Constructor "<<endl; rno=r; marks=m; } void printdet()

Advertisements
Advertisements

Question

Write the output of the following

#include<iostream>
using namespace std;
class student
{
  int rno, marks;
  public: student(int r, int m)
  {
    cout << "Constructor " << endl;
    rno = r;
    marks = m;
  }
  void printdet()
  {
    marks = marks + 30;
    cout << "Name: Bharathi" << endl;
    cout << "Roll no : "<<rno << "\n";
    cout << "Marks : "<<marks << endl;
  }
};
int main()
{
  student s(14,70);
  s.printdet();
  cout << "Back to Main";
  return 0;
}
Short/Brief Note
Advertisements

Solution

Constructor 
Name: Bharathi
Roll no : 14
Marks : 100
Back to Main
shaalaa.com
Introduction to Classes
  Is there an error in this question or solution?
Chapter 14: Classes and objects - Evaluation - Section - D [Page 248]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 11 TN Board
Chapter 14 Classes and objects
Evaluation - Section - D | Q 3. | Page 248
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×