- Home
- C Programming Home
- C Programming Exercises
- Home
- Basic Declarations and Expressions
- Basic Algorithm
- Variable Type
- Input - Output
- Conditional Statements
- For Loop
- Array
- Pointer
- Linked List
- Numbers
- String
- Date Time
- Math
- Function
- Recursion
- File Handling
- Algorithm
- Searching and Sorting Algorithm
- Practice
- ..More to come..
C Programming Exercises, Practice, Solution : Linked List
Last update on September 16 2021 07:04:13 [UTC/GMT +8 hours]C Linked List [30 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts.]
1. Write a program in C to create and display Singly Linked List. Go to the editor
Test Data :
Input the number of nodes : 3
Input data for node 1 : 5
Input data for node 2 : 6
Input data for node 3 : 7
Expected Output :
Click me to see the solution
2. Write a program in C to create a singly linked list of n nodes and display it in reverse order. Go to the editor
Test Data :
Input the number of nodes : 3
Input data for node 1 : 5
Input data for node 2 : 6
Input data for node 3 : 7
Expected Output :
Click me to see the solution
3. Write a program in C to create a singly linked list of n nodes and count the number of nodes. Go to the editor
Test Data :
Input the number of nodes : 3
Input data for node 1 : 5
Input data for node 2 : 6
Input data for node 3 : 7
Expected Output :
Click me to see the solution
4. Write a program in C to insert a new node at the beginning of a Singly Linked List. Go to the editor
Test Data and Expected Output :
Click me to see the solution
5. Write a program in C to insert a new node at the end of a Singly Linked List. Go to the editor
Test Data and Expected Output :
Click me to see the solution
6. Write a program in C to insert a new node at the middle of Singly Linked List. Go to the editor
Test Data and Expected Output :
Click me to see the solution
7. Write a program in C to delete first node of Singly Linked List. Go to the editor
Test Data :
Input the number of nodes : 3
Input data for node 1 : 2
Input data for node 2 : 3
Input data for node 3 : 4
Expected Output :
Click me to see the solution
8. Write a program in C to delete a node from the middle of Singly Linked List. Go to the editor
Test Data and Expected Output :
Click me to see the solution
9. Write a program in C to delete the last node of Singly Linked List. Go to the editor
Test Data :
Input the number of nodes : 3
Input data for node 1 : 1
Input data for node 2 : 2
Input data for node 3 : 3
Expected Output :
Click me to see the solution
10. Write a program in C to search an existing element in a singly linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
11. Write a program in C to create and display a doubly linked list. Go to the editor
Test Data :
Input the number of nodes : 3
Input data for node 1 : 2
Input data for node 2 : 5
Input data for node 3 : 8
Expected Output :
Click me to see the solution
12. Write a program in C to create a doubly linked list and display in reverse order. Go to the editor
Test Data :
Input the number of nodes : 3
Input data for node 1 : 2
Input data for node 2 : 5
Input data for node 3 : 8
Expected Output :
Click me to see the solution
13. Write a program in C to insert a new node at the beginning in a doubly linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
14. Write a program in C to insert a new node at the end of a doubly linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
15. Write a program in C to insert a new node at any position in a doubly linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
16. Write a program in C to insert a new node at the middle in a doubly linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
17. Write a program in C to delete a node from the beginning of a doubly linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
18. Write a program in C to delete a node from the last of a doubly linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
19. Write a program in C to delete a node from any position of a doubly linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
20. Write a program in C to delete a node from the middle of a doubly linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
21. Write a program in C to find the maximum value from a doubly linked list. Go to the editor
Test Data :
Input the number of nodes : 3
Input data for node 1 : 5
Input data for node 2 : 9
Input data for node 3 : 1
Expected Output :
Click me to see the solution
22. Write a program in C to create and display a circular linked list. Go to the editor
Test Data :
Input the number of nodes : 3
Input data for node 1 : 2
Input data for node 2 : 5
Input data for node 3 : 8
Expected Output :
Click me to see the solution
23. Write a program in C to insert a node at the beginning of a circular linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
24. Write a program in C to insert a node at the end of a circular linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
25. Write a program in C to insert a node at any position in a circular linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
26. Write a program in C to delete node from the beginning of a circular linked list. Go to the editor
Test Data :
Input the number of nodes : 3
Input data for node 1 : 2
Input data for node 2 : 5
Input data for node 3 : 8
Expected Output :
Click me to see the solution
27. Write a program in C to delete a node from the middle of a circular linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
28. Write a program in C to delete the node at the end of a circular linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
29. Write a program in C to search an element in a circular linked list. Go to the editor
Test Data and Expected Output :
Click me to see the solution
30. Write a C programming to sort a given linked list by bubble sort. Go to the editor
Test Data and Expected Output : 5
15
33
49
6
65
Click me to see the solution
C Programming Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
C Programming: Tips of the Day
It is more efficient to use if-return-return or if-else-return?
Since the return statement terminates the execution of the current function, the two forms are equivalent [although the second one is arguably more readable than the first].
The efficiency of both forms is comparable, the underlying machine code has to perform a jump if the if condition is false anyway.
Note that Python supports a syntax that allows you to use only one return statement in your case:
return A+1 if A > B else A-1
Ref : //bit.ly/3FjjGHs
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework