Program To Create A Linked List22
Program To Create A Linked List22
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
int main()
struct node
int num;
};
int count = 0;
int choice = 1;
first = 0;
while (choice)
if (first != 0)
{
temp->ptr = head;
temp = head;
else
fflush(stdin);
scanf("%d", &choice);
temp->ptr = 0;
temp = first;
while (temp != 0)
printf("%d=>", temp->num);
count++;
printf("NULL\n");
}
// Iterative C++ program to search
// an element in linked list
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
{
Node* current = head; // Initialize current
while (current != NULL)
{
if (current->key == x)
return true;
current = current->next;
}
return false;
}
/* 4. If the Linked List is empty, then make the new node as head */
if (*head_ref == NULL)
{
*head_ref = new_node;
return;
}
return 0;
}
void
print_linked_list()
{
printf("\nYour full linked list is\n");
node *myList;
myList = head;
while(myList!=NULL)
{
printf("%d ", myList->number);
myList = myList->next;
}
puts("");
}
Output:
Created Linked list is: 1 7 8 6 4