program Linked List:
modify the following program to make a node containing data values of int, char, and string.
#include using namespace std;struct node{int data;struct Node *next;};struct Node* head = nullptr;//or Null or 0;void insert(int new_data){struct Node* new_node=(struct Node*) new(struct Node);new_mode->data=new_data;new_mode->next=head;head=new_node;}void display(){struct Node* ptr;ptr=head;while(ptr ! = NULL){ coutdata<>ptr=ptr->next;}}int main(){insert{2};display{};return0;}
using namespace std;
struct node
{
int data;
struct Node *next;
};
struct Node* head = nullptr;//or Null or 0;
void insert(int new_data)
struct Node* new_node=(struct Node*) new(struct Node);
new_mode->data=new_data;
new_mode->next=head;
head=new_node;
}
void display()
struct Node* ptr;
ptr=head;
while(ptr ! = NULL)
coutdata<>ptr=ptr->next;}}int main(){insert{2};display{};return0;}
ptr=ptr->next;
int main()
insert{2};
display{};
return0;
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here