Program to print Detail of Student in C++.

In this program we print detail of Student by using class 

in C++.

 

Let’s write a program which print Detail of Student.

 

Step 1: Let’s Open turbo C++ And write the following Code:

 

//Code:

 

// Add peprocesser

 

#include<iostream.h>

#include<conio.h>

class student

{

private:

int age,roll;

char clas[10];

char name[20];

public :

void display();

void input();

};

void student :: input()

{

cout<<”enter name of student:”;

cin>>name;

cout<<”enter roll number:”;

cin>>roll;

cout<<”enter age:”;

cin>>age;

cout<<”enter class:”;

cin>>clas;

}

void student :: display()

{

cout<<”\t name”<<name;

cout<<”\t roll number”<<roll;

cout<<”\t age”<<age;

cout<<”\t class”<<clas;

}

void main()

{

student s;

s.input();

s.display();

getch();

}

 

 

Step 2: Run the program and see Output:

 

 

output:

 

output

 

Happy coding.

 

 

 

Tags: ,