C Program to Search for an Element in Linked List

Here we’ll see how to write a C program to find an element in a linked list. The function is_present() takes a linked list (head pointer) and a value (val) as input arguments. If the value (val) is present in any of the nodes, this function returns the pointer of that node. Otherwise it returns … Continue reading “C Program to Search for an Element in Linked List”

C Program to Print the Length of a Linked List

Here we’ll see how to write a C program to print the length of a linked list. The function get_length() takes a linked list as input and returns the length of it. First we’ll create a linked list and pass that list to the get_length() function to print the length of the list. The get_length() … Continue reading “C Program to Print the Length of a Linked List”

C Program to Check Whether Two Linked Lists are Equal

Here we’ll see how to write a C program to compare two linked lists. First we’ll create three linked lists, first two are equal and third one is different. We’ll compare these linked lists using the check_equal() function. The check_equal() function traverses the linked lists until at least one of them reaches to NULL (end). … Continue reading “C Program to Check Whether Two Linked Lists are Equal”

Command Line Arguments in C Programming

An application takes inputs in various ways. It can ask for input from user while it is running. It can read something from file or socket. Another way is, we can give inputs in time of starting the application in the form of command line arguments. For example, when we run Linux commands we give … Continue reading “Command Line Arguments in C Programming”

C Program to Calculate the Sum of All Elements in an Array

Here is the C program that prints the sum of all elements in an array. Output of this program: This program is good enough solution. If you are interested, you can see few other solutions in the following sections. Recursive Version We can wire a recursive function for the same purpose. Divide and Conquer We … Continue reading “C Program to Calculate the Sum of All Elements in an Array”

0
0
0
0
0
0