Life Hacks

# programs

## Write a program of the Quick Sort.

#include<iostream.h> #include<conio.h> int a[10], l, u, i, j; /* local variable */ void quick(int *, int, int); void main( ) /* main start */ { clrscr( ); cout << “ Enter 10 elements : ”; for(i = 0; i < 10; i ++) { cin >> a[i]; } /* End of for loop */ l […]

## Write a program of the Heap Sort.

#include<iostream.h> #include<conio.h> int arr[20], n; class heap { private: int loc, num, par; /* local variable */ public: void del_root(int); void create_heap( ); void display( ); void heap_sort( ); void insert(int, int); }; void heap :: insert(int num, int loc) { int par; /* local variable */ while(loc > 0) { par = (loc – […]

## Write a program of the Binary Search.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int a[20], n, c, lb, ub, item, mid, loc; /* local variable */ cout << " \n Enter the number of elements in an array is: " << " \n "; cin>>n; // entering no. of elements for the array. cout << " […]

## Write a program of the Insertion Sort.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int a[50], n, i, ptr, temp; /* local variable */ cout << " Enter the number of elements in an array is : ”; cin >> n; // Enter the no. of elements wants to be sorted. a[0] = 0; cout << " […]

## Write a program of the Selection Sort.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int array[10], n, i, j, temp; /* local variable */ cout << " Enter the number of elements in an array is : ”; cin >> n; // inserting no. of elements in the array. cout << “ Enter “ << “ “ […]

## Write a program of the Bubble Sort.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int num[56], n, k, c, ptr, temp; /* local variable */ cout<<"enter the number of elements in an array is : ”; cin>>n; // inserting no. of elements in the array. cout<<"enter the value of elements of array is : "; for(c = […]

## Write a program of the deletion in an array.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int a[20], j, n, k, b, c, item; /* local variable */ cout << " \n Enter the number of elements in an array is : " << " \n "; cin >> n; cout << " \n Enter the value of elements […]

## Write a program of the insertion in an array.

#include<iostream.h> #include<conio.h> void main( ) /* main start */ { clrscr( ); int a[20], j, n, k, b, c; /* local variable */ cout << " \n Enter the number of elements in an array is: " << " \n "; cin >> n; cout << " \n Enter the value of elements of array […]

## Bubble Sort in Cpp

#include <iostream.h>#include <string.h>#include <conio.h>    //jumbled up text in array    char strarray[] = “fgjhsflsdlkfghdksdkjdgskakdkfkjggkdkgjg”;    int i = 0;    int j = 0;    char temp;    void Bubble(char* strarray, int arrsize); int main()     {    cout << strarray << endl;    Bubble(strarray, strlen(strarray));    cout << strarray << endl;    return 0;} void Bubble(char* strarray, int arrsize) //Bubble Sort code     […]