# C Programming Code Examples

## C > For Loops and While Loops Code Examples

### Program to find sum of even numbers in given range

Trim Leading & Trailing white spaces from -
I already explained how to remove leading as well as trailing white space characters from a given string. In this program we will Combine the logic of both in a single program. Logic to

Code Perform Binary Search use Recursion -
C program, 'using recursion', performs binary search. In this c program, an array of random number is generated. User is asked to enter a key. The array of random numbers are sorted

C Construct a Balanced Binary Search Tree -
Code construct a balanced binary search tree which has same data members as the given doubly Linked list. This C Program creates a balanced binary search tree which has same

Multiple Initialization Inside For Loop in C -
1. It is initializing two variables. Note: both are separated by comma (,). 2. It has two test conditions joined together using AND (&&) logical operator. You cannot use multiple test

Calculates Area & Circumference of Circle -
To calculate area and circumference we must know the radius of circle. C program code will prompt user to enter the radius and based on the input it would calculate the values. Make

Code find sum of all elements of an array -
Write a C program to read elements in an array and find the sum of all elements of the array. C program to find sum of elements of the array. How to add elements of an array

Function strncpy Copies First n Characters -
If 'Length of str2' > n then it just copies first n characters of str2 into str1. If Length of str2 < n then it 'copies' all the characters of str2 into str1 & appends several 'terminator' chars('\0')

Find the Length of the Linked List without -
C Language program Find the Length of the linked list without using recursion. Program, using iteration, counts the number of nodes in a Linked List. A linked list is an ordered set