Create Doubly Linked List

Easy Doubly Linked List: Basics
Solve in Playground →

Problem Statement

Write a C program to create a doubly linked list with two nodes, linking their next and prev pointers correctly, and print both node values.

Input Format

Two space-separated integers for the two nodes.

Output Format

Print the data of both nodes separated by a space.

Constraints

Standard integer limits

Sample Input

10 20

Sample Output

10 20

Explanation

Define a doubly linked list node structure with data, next, and prev pointers. Allocate two nodes, set `node1->next = node2`, `node2->prev = node1`, and assign values.

Starter Code

#include <stdio.h>
#include <stdlib.h>

struct Node {
    int data;
    struct Node *next;
    struct Node *prev;
};

int main() {
    int val1, val2;
    if (scanf("%d %d", &val1, &val2) == 2) {
        // Write your code here to create doubly linked list nodes and print their data
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used