# C Programming Code Examples

## C > Mathematics Code Examples

### C Program to Find the Sum of H.P Series

C++ Program to Implement Counting Sort - In c++ sort pogram sample, count the number of 'occurrences' of each element. And store it in the Array of size same as the range of data input. Use element value to refer the counter

Find The Perfect Number In C++ language - For example 6 is Perfect Number since divisor of 6 are 1, 2 and 3. Sum of its divisor is 1 + 2+ 3 =6 and 28 is also a 'Perfect Number' since 1+ 2 + 4 + 7 + 14= 28. Other 'Perfect Numbers': 496

Program Solve The 0-1 Knapsack Problem - C++ Program to solve 0-1 'knapsack problem'. The 'Knapsack' problem or Rucksack problem is a problem in "Combinatorial Optimization": Given a Set of items, each with a mass, value,

C++ Programming Bubble Sort Algorithm - The Bubble Sort is a simple sorting algorithm that 'repeatedly' steps through the List to be sorted, compares each pair of adjacent items and swaps them if they're in the wrong order.

C programming Open and Copy Functions - Open a source file. If there is an error giving message: Cannot open source file. Open destination file. If there is error give message: Cannot open destination file. If file won't

Sort Array in Ascending Descending Order - Program code to read elements in an array and sort elements of the array in ascending order. Read unsorted integer values in array and sort them in ascending order. Numerous

Calculating Difference Between two Time - Ask to enter two time periods and these two periods are stored in structure variables t1 t2 respectively. The computeTimeDifference() Function calculates the Difference Between

C Find Prime Numbers Between the Range - The program takes the range and finds all the 'Prime Numbers' between the range & prints. Lets first take the range of numbers between which you have to find the prime numbers as