# C Programming Code Examples

## C > For Loops and While Loops Code Examples

### find sum of natural numbers from 1 to n

C++ Sample How to Use If Else Statement -
In Programming, The "if statement" by itself will execute a single statement, or a group of statements, when the expression following if evaluates to "true". It does nothing when the

C Count Trailing Zeros in a Binary Number -
C language input any number from user and count number of trailing zeros in the given number using bitwise operator. How to find total number of trailing zeros in any given...

C Put Even & Odd Elements of an Array in -
C Program puts even & odd elements of an array in 2 separate arrays. The program first finds the odd and even elements of the array. Then the odd elements of an array is stored

Finds HCF of given Number use Recursion -
Program to find HCF of a given number using recursion. Programming code using recursion finds the HCF of 2 entered integers. The 'HCF' stands for Highest Common Factor. Enter the

Program code to Reverse a Given Number -
Take the Number which you have to Reverse as the input. Obtain its quotient & remainder. Multiply the separate variable with 10 & add the obtained remainder to it. Do step 2 again

Generate Random Subset by Coin Flipping -
Prints a 'subset' of the given array using coin flipping method. The time complexity of this algorithm is O(n). Takes the input of 'n' data element and prints a possible subset. that, it

Counting program code in The C language -
Counting is sequence of whole numbers in ascending order without zero. Developing a program of counting in C language is easy and we shall see here in this chapter. Count

C Code Copy One String to Another String -
C program code to copy one string to another without using inbuilt library function 'strcpy()' Input string and 'store it' to some variable say text1. Declare another variable to 'store copy'