Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions: Write a C++ program to delete a name from a list of students name. You need to write function called delete_name. The delete_name function

Instructions:

Write a C++ program to delete a name from a list of students name. You need to write function called delete_name. The delete_name function will let the user to delete a name from any position from your list and not only from the end of your list. Using dynamic array!!

I have made a code but i dont know if it is correct or not.

MY C++ CODE:

#include #include using namespace std;

//Gv //function declaration string* new_name(string*, int&); void display_names(string*, int); //main int main() { //local var int size = 3; string *students_names = new string[size];

//code cout << "enter" << size << "student names:" << endl; for (int i = 0; i < size; i++) cin >> students_names[i];

students_names =add_name(students_names, size); display_names(students_names, size);

delete[] students_names; system("pause"); return 0; }//main //function definition string* delete_name(string*s_names, int&size); void display_names(string *names, int s); { //local var string delete_name; string *temp = new string[size - 1]; //code cout << "enter the new name to delete to the list:"; cin >> delete_name;

for (int i = 0; i < size; i++) temp[i] = s_names[i]; temp[size] = delete_name;

delete[1] s_names; size++ return temp; } string * delete_name(string *, int &) { return nullptr; } //delete_name void display_names(string *names, int s) { for (int i = 0; i < s - 1; i++) cout << "Name" << i << ":" << names[i] << endl; return; }//display_name

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

What do you need to know about your students to motivate them?

Answered: 1 week ago