Functions in C

  • + 0 comments

    include

    include

    using namespace std; struct Student { string name; float marks[3]; }; int main() { Student s[50]; int n = 0, choice; do { cout << "\n1.Add Student 2.Display All 3.Search 4.Topper 5.Exit\n"; cout << "Enter choice: "; cin >> choice; if(choice == 1) { cout << "Enter student name: "; cin >> s[n].name; cout << "Enter marks in 3 subjects: "; for(int i=0;i<3;i++) cin >> s[n].marks[i]; n++; } else if(choice == 2) { for(int i=0;i "; for(int j=0;j<3;j++) cout << s[i].marks[j] << " "; cout << endl; } } else if(choice == 3) { string key; cout << "Enter name to search: "; cin >> key; for(int i=0;i best) { best = avg; topper = s[i].name; } } cout << "Topper: " << topper << " with avg " << best << endl; } } while(choice != 5); }