C++ Program to print student details using structure


In this program, You will learn how to print student details using structure in C++.


struct struct_name { };


Example: How to print student details using structure in C++

Run it Now
#include<iostream>
using namespace std;

struct Student {
    int roll;
    char name[100];
    char university[100];
};

int main() {

    struct Student st;

    cout << "Enter Your Roll :";
    cin >> st.roll;
    cin.get();

    cout << "\nEnter Your Name :";
    cin.getline(st.name, 100);

    cout << "\nEnter University Name :";
    cin.getline(st.university, 100);

    cout << "\nYour Roll is :" << st.roll;
    cout << "\nYour Name is :" << st.name;
    cout << "\nYour University is :" << st.university;

    return 0;
}

Output:

Enter Your Roll :101
Enter Your Name :John
Enter University Name :Texas
Your Roll is :101
Your Name is :John
Your University is :Texas