0% found this document useful (0 votes)
4 views1 page

C++ Student Details Program

The document contains a C++ program that defines a class 'Sahil' to manage student details, including name and roll number. It includes methods to get user input for these details and to display them. The main function creates an instance of the class, retrieves the student's information, and then displays it.

Uploaded by

yatharthhatwar7
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)
4 views1 page

C++ Student Details Program

The document contains a C++ program that defines a class 'Sahil' to manage student details, including name and roll number. It includes methods to get user input for these details and to display them. The main function creates an instance of the class, retrieves the student's information, and then displays it.

Uploaded by

yatharthhatwar7
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

Practical : 1

#include <iostream>
using namespace std;

class Sahil {
private:
string name;
int roll_number;

public:
void getDetails() {
cout << "Enter student's name: ";
getline(cin, name);
cout << "Enter roll number: ";
cin >> roll_number;
}

void displayDetails() {
cout << "\nStudent Details:\n";
cout << "Name: " << name << endl;
cout << "Roll Number: " << roll_number << endl;
}
};

int main() {
Sahil s1;

cout << "Enter student details:\n";


[Link]();

cout << "\nDisplaying details:\n";


[Link]();

return 0;
}

Output of the program:

You might also like