Professional Documents
Culture Documents
struct Student {
string name;
int regNo;
int marks;
};
int main() {
Student students[numStudents];
cout << "Enter details for student " << i + 1 << ":" << endl;
}
// Display details of each student
return 0;
Certainly! Here's an example of a C++ program that uses a structure to store and display details of 100
students, including their full name, registration number, and marks:
```cpp
#include <iostream>
struct Student {
string fullName;
int regNumber;
int marks;
};
int main() {
Student students[100];
cout << "Enter details for student " << i+1 << ":" << endl;
getline(cin, students[i].fullName);
cout << "Student " << i+1 << ":" << endl;
return 0;
```
In this program, we define a structure named `Student` with three members: `fullName` (string),
`regNumber` (integer), and `marks` (integer).
We declare an array of `Student` structures named `students` with a size of 100 to store the details of
100 students.
The program then prompts the user to input the details for each student using a loop. It asks for the full
name, registration number, and marks for each student. The `getline` function is used to read the full
name, while the `>>` operator is used to read the registration number and marks.
After inputting the details, the program displays the details of all students using another loop.
Note that the program assumes valid input and doesn't perform any error checking. It also uses `using
namespace std;` for simplicity, but it's generally recommended to avoid this practice in larger program