C Practice Programs- 2

  1. Write a function to find the middle element of a given singly linked list in C.

Input:               Head of linked list

Output:            Middle value of the list

For example, if the given linked list is 1->2->3->4->5 then, output should be 3.

If there are even number of elements, then there would be two middle elements, then output should be the second middle element.

For example, if given linked list is 1->2->3->4->5->6 then, output should be 4.


  1. Program to split string by single space into words ?

Input: Welcome to C Programming

Output:

Welcome

to

C

Programming

No. of words: 4


  1. Given two numbers, find the sum of prime numbers between them, both inclusive.

Input    : 1 5

Output : 10


  1. Write a program to find the second largest number in the integer array, A, of size N.

Range: 0≤A≤100  0≤N≤100

Input    : 8 11 22 6 8 9 18 19 10  //here first 8 indicates size of array.

Output : 19



You can find the solution programs here C Programming 2

If you have any queries fell free to ask them here.

Leave a comment

Design a site like this with WordPress.com
Get started