Skip to main content

Posts

Showing posts with the label Write a program with member functions: one that initializes necessary data members

Create a class named Student with six data members (name, roll, and marks in Math, English and Programming, total_marks). Write a program with member functions: one that initializes necessary data members, another one that calculate total marks and another one that displays student's detail. In main(), create two objects of class Student, for each object, invoke the functions defined above in the class.

 Here's the program that creates a class named Student and its member functions to initialize data members, calculate total marks and display student's details: #include <iostream> #include <string> using namespace std; class Student {     private:         string name;         int roll, math_marks, english_marks, programming_marks, total_marks;          public:         void set_data() {             cout << "Enter student's name: ";             cin >> name;             cout << "Enter student's roll number: ";             cin >> roll;             cout << "Enter marks in Math: ";             cin >> math_marks;             cout << "E...