Write a C++ Program.
Create a structure course with some attributes i.e course_ID, course_title, credit_hrs etc.. Then Implement
following 5 functions (Known as CRUDS operations which means CREATE, READ, UPDATE, DELETE,
SEARCH operations):
1. addAStudent
2. updateAStudent
3. deleteAStudent
4. searchAndDisplayAStudent
5. displayAllstudents
After that, create an array of 5 courses in main function. Create a menu in main function to enable user to
select and perform the operations we created above. Program must not exit until and unless user wants to
do so.
Sample Menu:
Main Menu
---------------
Press 1 to add a Course
Press 2 to update a Course
Press 3 to delete a Course
Press 4 to search and display a Course
Press 5 to display all Courses
Press e to exit the program
Answers
Answer:
I don't know what is the answer but you can question me on English
Explanation:
have a good day
Answer:
Explanation:
#include <iostream>
using namespace std;
int student = 2;
int add = 0;
int updated=0;
int dele = 0;
int* ptr1=0;
struct course
{
int cours_id;
string cours_title;
int credit_hrs;
};
void showmenu()
{
cout << "*******Menu********" << endl;
cout << " 1. Add a student " << endl;
cout << " 2. update a student " << endl;
cout << " 3. delete a student " << endl;
cout << " 4. display all students" << endl;
cout << " 5.Exist" << endl;
cout << "**********************" << endl;
}
void Add()
{
cout << "add" << endl;
cin >> add;
cout << "add" << student + add<<endl;
ptr1 = &student;
*ptr1 = student + add;
}
void update()
{
cout << "how many student you are updated:"<<endl;
cin >> updated;
*ptr1 = student + updated;
cout << *ptr1 << endl;
}
void del()
{
cout << "how many student you delet" << endl;
cin >> dele;
*ptr1 = student -dele;
cout << *ptr1;
}
void display()
{
*ptr1 = student + add;
cout << "ADD: " << *ptr1<<endl;
*ptr1 = student + updated;
cout << "updated student:" << *ptr1<<endl;
*ptr1 = student - dele;
cout << "Delete: " << *ptr1<<endl;
course student;
for (int i = 0; i < *ptr1; i++)
{
cout << "student[" << i << "]" << endl;
cin >> student.cours_id;
cin >> student.cours_title;
cin >> student.credit_hrs;
}
for (int i = 0; i < *ptr1; i++)
{
cout << "student[" << i << "]" << endl;
cout<< student.cours_id<<endl;
cout<< student.cours_title<<endl;
cout<< student.credit_hrs<<endl;
}
}
int main()
{
int option;
do{
showmenu();
cout << "Option:";
cin >> option;
switch (option)
{
case 1:
Add();
break;
case 2:
update();
break;
case 3:
del();
break;
case 4:
display();
break;
}
} while (option != 5);
}