C codes.

# Bubble sort on array

Algorithm: Bubble Sort

Code:

# Quick Sort on Array

Algorithm: Quick Sort on Array
Complexity : Average case O(n logn) , worst Case O(n^2)

Code:

Quick sort on array.

# Heap Sort on array

Algorithm : Heap Sort on Array
Complexity :O(n logn)

Heap sort in Array code in C .

# insertion sort on array

Algorithm : Insertion Sort on array
Complexity : O(n^2)

Insertion sort on array code in C .

# Sort an array in C (Basic Method)

Complexity : O(n2)

Explanation:

Below code picks a cell one by one and compares with each other cells , if value of current cell is greater than other cell then it will swap with other value. Similarly it performs untill picked cell is last cell.

Code :

# C program to find given element in array

C program to find given element in array

Explanation :

So far we have seen how to take input in array and printing the same. We have got knowledge, how to scan an array ? Right…  In this post we are finding an element if it found then we have to print its position otherwise say “Element not found “. We have read the relational operators which are used to compare values.

step 0 : initialize found variable as 0 means notfound

step1: Input the array and value to be searched

Step2 : Scan the array from start position to size of array

— check for equality of array element (arr[i] ) and search value (findval) using (arr[i]==findval)

— above condition is true then initialize fount=1 and break the loop

step3 : if found==1 then print the found value and position too.

Code :

C program to find given element in array.

# A C code to print array reverse

A C code to print array reverse (printing array from last position to first)

Explanation : To print element in reverse order we must start loop from last position of array and then print upto it reaches to zeroth position. Code :

# A C Code to Input array and print the same

Input array and print the same.

Explanation :

we can access element in array using array name and [ ]. Just specify the position within square bracker [ ] just after the array variable name.

Here we have defined int array of size 100. We have defined size variable which can go max upto 100 (because array size max can reach upto 100). Then we have taken size as input using scanf function then we have initialized for loop from zero because array starts default from zero in C. We will  run the loop upto size-1 which is controlled by (i<size) . In the body part of for loop we have given arr[i] as argument in scanf function, to store value from input into arr[i] untill loop gets terminated.

After inputting array we are printing array using for loop.

Input array and print the same code in C.

# Input integer array in C

String is also an array of char but we have functions to take input string . For inputting the int array ,float array we dont have functions like string. Here is the code for inputting integer array , similarly we can apply it for float too.

Example :