This C Program uses recursive function & counts the number of nodes in a linked list. A linked list is an ordered set of data elements, each containing a link to its successor.
Here is the source code of the C program to count the number of nodes in a linked list. The C Program is successfully compiled and run on a Linux system. The program output is also shown below.
* Recursive C program to find length of a linked list
int find_len (char , int);
int main ()
int len = 0;
printf ("Enter the string: \n");
scanf ("%[^\n]s", str);
len = find_len (str, 0);
printf ("The length of the given string is: %d\n", len);
int find_len (char str, int index)
static int l = 0;
if (str[index] == '\0')
find_len (str, index + 1);
Enter the string: Sanfoundry C Programming The length of the given string is: 24 Enter the string: Programming Examples The length of the given string is: 20
Sanfoundry Global Education & Learning Series – 1000 C Programs.