C++ Program to print student details using a structure
In this program, You will learn how to print student details using structure in C++.
struct struct_name {
//variable declaration
};
Example: How to print student details using structure in C++.
#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 << "Enter your name:";
cin.getline(st.name, 100);
cout << "Enter 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:Xiith.com
Enter university name:Xiith34
Your Roll is:101
Your Name is:Xiith.com
Your University is:Xiith34