# C Programming Code Examples

## C > For Loops and While Loops Code Examples

### Program to count number of digits without using loop

Checking Whether Number is Even or Odd -
In this example, if...else statement is used to check whether a number entered by the user is "even or odd". Integers which are perfectly "divisible by 2" are called even numbers. And

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++ Program Calculate GCD of 2 Integers -
Examples on different ways to calculate GCD of two integers (for both Positive & Negative integers) using "Loops and Decision" making statements. The "Largest integer" which can

C Language & CPU Scheduling Algorithm -
C Program Checks if the mouse pointer is over the button. Checks whether count=1 so as to display the button on the new position for only once. Creates a box and the box is...

Random Numbers Probability Distribution -
Program to generate random numbers using Probability Distribution Function. Probability distribution is based on "Probability Density" function. a probability density function (pdf),

Qsort Sort [array of pointers to structures] -
Code compare function for qsort. Add ONE element to the array. Allocate memory for ONE 'struct node'. Copy the data into the new element ( structure ). Qsort array of...

C Program Code Finds Area of a Rectangle -
Input length and width of a rectangle and find area of the given rectangle. How to calculate area of a rectangle in C programming. Input length and width of rectangle. Store it in two

Display its own Source Code as its Output -
Display the content from the same file you are writing the source code. Open the file you are currently writing using statement fopen and assign it to the pointer fp. Scan the every