java3
java3
h>
#include<stdlib.h>
struct node
{
int data;
struct node *next;
};
struct node *head=NULL;
void beginsert()
{
struct node *ptr;
int item;
ptr = malloc(sizeof(struct node *));
printf("\nEnter value\n");
scanf("%d",&item);
ptr->data = item;
ptr->next = head;
head = ptr;
printf("\nNode inserted");
void display()
{
struct node *ptr;
ptr = head;
void main ()
{
int choice =0;
while(1)
{
if (head == NULL) {
head = newNode;
return;
}
temp->next = newNode;
}
if (temp == NULL) {
printf("Index out of range\n");
free(newNode);
return;
}
newNode->next = temp->next;
temp->next = newNode;
}
// Insert at middle