New paste Repaste Download
#include<bits/stdc++.h>
using namespace std;
struct Node {
int data;
Node *next;
};
Node *head = NULL;
void insertAtBeginning(int value)
{
    Node *newNode = new Node();
    newNode -> data = value;
    newNode -> next = head;
    head = newNode;
    return;
}
void insertAtPosition(int value, int position)
{
    Node *newNode = new Node();
    newNode -> data = value;
    if (position == 1)
    {
        newNode -> next = head;
        head = newNode;
        return;
    }
    Node *temp = head;
    for (int i = 1; i < position - 1 && temp != NULL; i++){
        temp = temp -> next;
    }
    newNode -> next = temp -> next;
    temp -> next = newNode;
}
void display()
{
    Node *temp = head;
    while (temp != NULL){
        cout << temp
    }
}
Filename: None. Size: 798b. View raw, , hex, or download this file.

This paste expires on 2025-09-07 03:17:55.794352. Pasted through web.