This programe is written in c++ language and this may help you in making your university assignment and projects.
Description :
In this programe i used concept of Nested structures to maintain a list of students consisting of their Roll No. , Name, Age, Current Semester, CGPA, Faculty, Date of Birth, Address, Cell No and Courses.
Functions :
- Initialize a class
- Find a student
- Update a student’s record
- Display all records
C++ Code :
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
#include<iostream> #include<cstring> #include<stdlib.h> #include<conio.h> using namespace std; struct student { string rollno; string age ; string current_semester; string name; string adress; string CGPA; string d_o_b; string cellNo; struct course { string title; string credit_hours; string course_code; }C[5]; }; int main () { int size=10,choice=0; student S[size]; while(choice<5) { cout<<" ***************************************"<<endl; cout<<" MANU\n"<<endl; cout<<"1. Initialize a class"<<endl; cout<<"2. Find a student"<<endl; cout<<"3. Update a student's record"<<endl; cout<<"4. Display all records"<<endl; cout<<"5. Exit programe "<<endl; cin>>choice; switch(choice) { case 1: { system("CLS"); cout<<endl<<endl; cout<<"\t\tPlease Enter Strenght of Class. "<<endl; cin>>size; cout<<endl<<endl; cout<<"\t\t\t Initialize Class ."<<endl; int i=0; getline(cin,S[i].name); for(;i<size;i++) { cout<<"Enter Name : "; getline(cin,S[i].name); cout<<"Enter RollNo : "; getline(cin,S[i].rollno); cout<<"Enter Age : "; getline(cin,S[i].age); cout<<"Enter Date of birth : "; getline(cin,S[i].d_o_b); cout<<"Enter Current Semester : "; getline(cin,S[i].current_semester); cout<<"Enter CGPA : "; getline(cin,S[i].CGPA); cout<<"Enter CellNo : "; getline(cin,S[i].cellNo); cout<<"Enter Adress : "; getline(cin,S[i].adress); cout<<endl<<endl; cout<<"\t\t\tCourses Details. "; cout<<endl<<endl; for(int j=0;j<5;j++) { cout<<"\t\t\tCourse "<<(j+1)<<endl<<endl; cout<<"Enter Title of course : "; getline(cin,S[i].C[j].title); cout<<"Enter Credit hours of course : "; getline(cin,S[i].C[j].credit_hours); cout<<"Enter Course code : "; getline(cin,S[i].C[j].course_code); } } break; } // case 1 ending case 2: { system("CLS"); string reg; cout<<endl<<endl; cout<<"\t\tEnter Student RegNo : "; cin>>reg; system("CLS"); for(int i=0;i<size;i++) { if(reg==S[i].rollno) { cout<<endl<<endl; cout<<"Name : "<<S[i].name<<endl; cout<<"RollNo : "<<S[i].rollno<<endl; cout<<"Age : "<<S[i].age<<endl; cout<<"Date of birth : "<<S[i].d_o_b<<endl; cout<<"Current Semester : "<<S[i].current_semester<<endl; cout<<"Cell NO. : "<<S[i].cellNo<<endl; cout<<"Address : "<<S[i].adress<<endl; cout<<"CGPA : "<<S[i].CGPA<<endl<<endl; for(int j=0;j<5;j++) { cout<<"\t\t\tCourse "<<(j+1)<<" Description."<<endl<<endl; cout<<"Title : "<<S[i].C[j].title<<endl; cout<<"Credit Hours : "<<S[i].C[j].credit_hours<<endl; cout<<"Course Code : "<<S[i].C[j].course_code<<endl; } } else { cout<<endl<<endl; cout<<"\t\tRecord Not Found."; } } break; } //case 2 ending case 3: { system("CLS"); string y; cout<<"Enter RegNo. of Student : "; cin>>y; system("CLS"); int a; int b; cout<<endl<<endl; for(int i=0;i<size;i++) { if(y==S[i].rollno) { do{ cout<<"Select One Option to update record"<<endl<<endl; cout<<"1. Name \t"; cout<<"2. RollNo \t"; cout<<"\t3. Age \t"<<endl; cout<<"4. Adress \t"; cout<<"5. CGPA \t"; cout<<"\t6. Current Semester\t"<<endl; cout<<"7. CellNo\t"; cout<<"8. Date Of Birth\t"; cout<<"9. Courses"<<endl; cin>>a; if(a<1 || a>9) { cout<<"Incorrect Option"<<endl; cout<<"Please Enter Again : "; cin>>a; } if(a==1) { getline(cin,S[i].name); cout<<"Please Enter New Name : "; getline(cin,S[i].name); } if(a==2) { getline(cin,S[i].rollno); cout<<"Please Enter New RollNo. : "; getline(cin,S[i].rollno); } if(a==3) { getline(cin,S[i].age); cout<<"Plaese Enter New Age : "; getline(cin,S[i].age); } if(a==4) { getline(cin,S[i].adress); cout<<"Please Enter New Address : "; getline(cin,S[i].adress); } if(a==5) { getline(cin,S[i].CGPA); cout<<"Please Enter New CGPA : "; getline(cin,S[i].CGPA); } if(a==6) { getline(cin,S[i].current_semester); cout<<"Please Update Current Semester : "; getline(cin,S[i].current_semester); } if(a==7) { getline(cin,S[i].cellNo); cout<<"Please Update CellNo. : "; getline(cin,S[i].cellNo); } if(a==8) { getline(cin,S[i].d_o_b); cout<<"Please Update Date Of Birth : "; getline(cin,S[i].d_o_b); } if(a==9) { cout<<"Update Courses Record"<<endl<<endl; for(int j=0;j<5;j++) { cout<<"\t\tUpdate Rcord of Course "<<(j+1)<<"."<<endl<<endl; cout<<"Title : "<<S[i].C[j].title<<endl; cout<<"Credit Hours : "<<S[i].C[j].credit_hours<<endl; cout<<"Course Code : "<<S[i].C[j].course_code<<endl; } } cout<<"Do You Want To Update Another Record (0,1) : "; cin>>b; }while(b !=0); break; } } break; } // case 3 ending case 4: { system("CLS"); cout<<endl<<endl; for(int i=0;i<size;i++) { cout<<"\t\t\tRecord Of Student "<<(i+1)<<" ."<<endl<<endl; cout<<"Name : "<<S[i].name<<endl; cout<<"RollNo : "<<S[i].rollno<<endl; cout<<"Age : "<<S[i].age<<endl; cout<<"Date of birth : "<<S[i].d_o_b<<endl; cout<<"Current Semester : "<<S[i].current_semester<<endl; cout<<"Cell NO. : "<<S[i].cellNo<<endl; cout<<"Address : "<<S[i].adress<<endl; cout<<"CGPA : "<<S[i].CGPA<<endl<<endl; for(int j=0;j<5;j++) { cout<<"\t\t\tCourse "<<(j+1)<<" Description."<<endl<<endl; cout<<"Title : "<<S[i].C[j].title<<endl; cout<<"Credit Hours : "<<S[i].C[j].credit_hours<<endl; cout<<"Course Code : "<<S[i].C[j].course_code<<endl; } } break; } //case 4 ending }// switch ending if (choice==4) break; }//while( choice!=5); // while ending cout<<endl<<endl; cout<<"\t\t\tPrograme Is Terminated"; return 0; system("pause"); } // int main ending |
click and Downlaod cpp file