60 331
Assignments Done
98%
Successfully Done
In April 2018

Answer to Question #12244 in C++ for Bassam

Question #12244
Write a program to copy the content of the following array to a dynamic single linked list, and write a function to delete every node has an even value in its data ?
Expert's answer
struct node{
int value;
struct node* next;
};
node* root = new node;

void toList(int* array, int size){
root->value = array[0];
root->next = NULL;
node* temp = root;
for(int i = 1; i < size; i++){
node* n = new node;
n->next = NULL;
n->value = array[i];
temp->next = n;
temp = n;
}
}

void remove(){
node* temp = root;
while(temp->next != NULL){
if(temp->next->value % 2 == 0){
temp->next= temp->next->next;
}
else
temp = temp->next;
}
if(root->value % 2 == 0)
root = root->next;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions