#include <iostream>
using namespace std;
class student
{
int rollno;
char name[30];
public:
void getdata();
void display ();
};
void student::getdata()
{
cout <<"Enter the roll no :";
cin>>rollno;
cout <<rollno<<endl;
cout <<"Enter the name: ";
cin>>name;
cout <<name<<endl;
}
void student ::display()
{
cout <<"Roll no: "<<rollno<<endl;
cout <<"Name : "<<name <<endl;
}
int main() {
student s[3];
for (int i=0;i<3;i++)
{
s[i].getdata ();
}
cout <<"***************"<<endl;
for (int i=0;i<3;i++)
{
s[i].display();
}
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: