Question: Data structures: In C++ write a simple code to insert, delete and print using while if and for loops, no classes. Have user input data

Data structures: In C++ write a simple code to insert, delete and print using while if and for loops, no classes.

Have user input data with cout and cin. and have the user clarify using ('P' 'I' or 'D' which operation they want for the node) Ex. if(letter='D', ){

Include a counter for nodes counter-1 for delete and counter +1 for insert.

this is what i have so far.

#include using namespace std;

int counter=0;

struct node { int info; node* link; };

cout<<"Enter I-insert P-print D-delete node"<>letter; int main(){ if (letter='I'){ new node; newNode->info=data; newNode->link=head; new node newnode; cin>>newNode->link=head; head=newNode; if(letter='P'){ current=head; while (current->link != NULL){ cout<info; current=current->link; } else if( letter='D') //delete funtion for(i=1, i <= counter; i++){ current=head; cin>>data; if( current->info=data) current->link=current->link->link; cin>>counter; } delete current; } } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!