Explanation of Question: Write a program to make the class of a student to enter name,class,roll no and father name using int get() to take input and int out function to display input.
use dev c++ to run this program.
#include<iostream>
using namespace std;
class student //declaring class , the class name is student
{
private: // using private access specifiers
int Roll;
char Name[40]; //it can take the input of 40 characters
char cls[10]; //it can take the input of 10 characters
char Fathername[40]; //it can take the input of 40 characters
public: //access specifiers
int get() //using function to take input
{
//stating fuction body
cout<<“Enter the name: “<<endl;
gets(Name); //using gets to use space in name
cout<<“Enter the Father name: “<<endl;
gets(Fathername);
cout<<“Enter the Roll No: “<<endl;
cin>>Roll;
cout<<“Enter the class: “<<endl;
cin>>cls;
}
int out() //using function to get/display output
{
//starting function body
cout<<“The Name is “<<Name<<endl;
cout<<“The Roll No is “<<Roll<<endl;
cout<<“The Father Name is “<<Fathername<<endl;
cout<<“The class is “<<cls<<endl;
}
}; //end of class
int main()
{
student s1;
s1.get();
s1.out();
system(“pause”);
}