Search This Blog

Loading...

Write a C++ program which is having class named student .It has two member functions named “read_data()” and “print_data()”. It has member elements called Rollno,Name and Percentage. Assume suitable data type for variable. And read the data from the user and print the same on the screen using above functions. : GTU Nov-Dec 2010

#include<iostream.h>

class students
{
    char *StudentName;
    int StudentRollNo;
    float StudentPercentage;
    public :
    void read_data(void)
    {
        cout << "\n Please Enter Student Name : ";
        cin >> StudentName;
        cout << "\n Please Enter Student Roll No : ";
        cin >> StudentRollNo;
        cout << "\n Please Enter Percentage : ";
        cin >> StudentPercentage;
    }

    void print_data(void)
    {
        cout << "\n\n\n Student Name : " << StudentName;
        cout << "\n Student Roll No : " << StudentRollNo;
        cout << "\n Student Percentage : " << StudentPercentage;
    }
}

main()
{
    students s;
    s.read_data();
    s.print_data();
}

No comments:

Post a Comment