0% found this document useful (0 votes)
15 views2 pages

Program 2

Uploaded by

s2729811
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Program 2

Uploaded by

s2729811
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy