Accept & Display student details - C++ Program

Q. Write a C++ program to accept and display the name, roll number and fees of a student using structure.


Following program is accepting and displaying the student details using structure.

using namespace std;
struct student    //Defining structure
        char sname[20];
        int rollno;
        float fee;
int main()
        struct student st;  //Declare st of type student
        cout<<"\n Enter Student Details "<<" ";
        cout<<"\n ---------------------------------\n";
        cout<<" Student Name : ";
        //Accessing member of structure using member access operator (.)
        cout<<" Roll Number : ";
        cout<<" Student Fee : ";

        cout<<"\n\n Student Details\n"<<" ";
        cout<<"\n Student Name : "<<st.sname;
        cout<<"\n Roll Number : "<<st.rollno;
        cout<<"\n Student Fee : "<<st.fee;
        return 0;


display student details