Question: Turn in all the c + + code down below into C #include #include #include List.h using namespace std; List::List ( ) { head

Turn in all the c++ code down below into C
#include
#include
#include "List.h"
using namespace std;
List::List(){
head = NULL;
curr = NULL;
temp = NULL;
}
void List::AddNode(int addData){
nodePtr n = new node;
n->next = NULL;
n->data = addData;
if(head != NULL){
curr = head;
while(curr->next != NULL){
curr = curr->next;
}
curr ->next = n;
}
else
{
head = n;
}
}
void List::DeleteNode(int delData){
nodePtr delPtr = NULL;
temp = head;
curr = head;
while(curr != NULL && curr->data != delData){
temp = curr;
curr = curr->next;
}
if(curr == NULL){
cout << delData << "was not in the list
";
delete delPtr;
}
else{
delPtr = curr;
curr = curr->next;
temp->next= curr;
if(delPtr == head){
head = head->next;
temp = NULL;
}
delete delPtr;
cout << "The value" << delData << "was deleted
";
}
}
void List::PrintList(){
curr = head;
while(curr != NULL)
{
cout << curr ->data << endl;
curr = curr->next;
}
}
Turn in all the c++ code down below into C
#include
#include "List.h"
using namespace std;
int main(int argc, char** argv{
List Rachael;
Rachael.AddNode(3);
Rachael.AddNode(5);
Rachael.AddNode(7);
Rachael.PrintList();
Rachael.DeleteNode(5);
Rachael.PrintList();
return 0;
})
#ifndef LIST_H
#define LIST_H
class List {
private:
typedef struct node {
int data;
node* next;
}*nodePtr;
nodePtr head;
nodePtr curr;
nodePtr temp;
public: //This is where the functions go
List();
void AddNode(int addData);
void DeleteNode(int delData);
void PrintList();
};
#endif

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!