Store information of 10 students using Structure
In this example, you will learn to make a C++ program to Store information of 10 students using structures.
Example of C++ program to Store information of 10 students using structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include<iostream> using namespace std; struct BCAstudent { char name[30]; int roll; float marks; }; int main() { int i; BCAstudent bs[10]; for(i=0;i<10;i++) { cout << "\nEnter name, Roll No, Marks of student "<<i+1<<" => "; cin >> bs[i].name; cin >> bs[i].roll; cin >> bs[i].marks; } cout << "\nPrint data Record......"; for(i=0;i<10;i++) { cout << "\nName: " << bs[i].name ; cout <<"\nRoll: " << bs[i].roll ; cout << "\nMarks: " << bs[i].marks; } return 0; } |
Output
Enter name, Roll No, Marks of student 1 => ajay 1 78
Enter name, Roll No, Marks of student 2 => kishan 2 67
Enter name, Roll No, Marks of student 3 => aliya 3 92
Enter name, Roll No, Marks of student 4 => rohan 4 85
Enter name, Roll No, Marks of student 5 => kartik 5 78
Enter name, Roll No, Marks of student 6 => rohan 6 94
Enter name, Roll No, Marks of student 7 => rajiv 7 82
Enter name, Roll No, Marks of student 8 => tanishq 8 69
Enter name, Roll No, Marks of student 9 => neha 9 72
Enter name, Roll No, Marks of student 10 => divyansh 10 89
Print data Record……
Name: ajay
Roll: 1
Marks: 78
Name: kishan
Roll: 2
Marks: 67
Name: aliya
Roll: 3
Marks: 92
Name: rohan
Roll: 4
Marks: 85
Name: kartik
Roll: 5
Marks: 78
Name: rohan
Roll: 6
Marks: 94
Name: rajiv
Roll: 7
Marks: 82
Name: tanishq
Roll: 8
Marks: 69
Name: neha
Roll: 9
Marks: 72
Name: divyansh
Roll: 10
Marks: 89
Check out our other C++ programming Examples