Program 2
#include<iostream>
using namespace std;
class Student {
private:
string name;
int age;
string rollNumber;
string course;
string address;
public:
// Method to input student details
void inputData() {
cout << "Enter Name: ";
cin>>name;
//getline(cin, name);
cout << "Enter Age: ";
cin >> age;
//cin.ignore(); // To ignore the newline character from previous input
cout << "Enter Roll Number: ";
cin>>rollNumber;
//getline(cin, rollNumber);
cout << "Enter Course: ";
cin>>course;
//getline(cin, course);
cout << "Enter Address: ";
cin>>address;
//getline(cin, address);
}
// Method to display student bio-data
void displayData() {
cout << "Student Bio-Data:" << endl;
cout << "Name: " << name << endl;
cout << "Age: " << age << endl;
cout << "Roll Number: " << rollNumber << endl;
cout << "Course: " << course << endl;
cout << "Address: " << address << endl;
}
};
int main() {
// Create an object of the class Student
Student student1;
// Input the bio-data
student1.inputData();
// Display the bio-data
student1.displayData();
return 0;
}
OUTPUT