C++ Programming Tutorial


Data File Structure Programs


Insert, edit, delete, append, display, Srch. Insert, delete, merge, delete multiple occurrences Arrays as a Stack in graphics


Stack operations using array Stack using static memory allocation Stack using dynamic memory allocation Double ended link list as a stack Lnked list as a Stack Infix expr. to Postfix expr. Postfix expr. into an Infix expr. Arrays as a Stack in graphics Stack as an Arithmetic expr. Evaluater Graphical Rep. of Stack Stack to traverse - inodr, postodr, preodr


Queue using static memory allocation Queue using dynamic memory allocation Circular queue Linked list as a Queue Double Ended linked list as a Queue Graphical Rep. of Queue Arrays as a Linear Queue Array as a Circular Queue Arrays as a Linear Queue ( in graphics ) Arrays as a Circular Queue ( in graphics )

Linked List

Singly link list Circular linked list Doubly link list Linked list as a Queue Linked list as a Stack Double Ended linked list as a Queue Double Ended linked list as a Stack Infix to Postfix - Linked List as Stack Circular doubly link list Single Ended Linked List - Sorting in both odr Hashing - double ended Linked List Sort of link list


Linked List as a Binary Srch. Tree Set Class using Binary Srch. Tree Maximum depth of Binary Srch. Tree Minimum Spaning Tree Prims algo - minimum spanning tree Traverse binary tree - inodr, preodr, post Find number in binary Srch. tree display levell


Bubble Sort Selection Sort Insertion Sort Radix Sort Merge Sort Quick Sort Heap Sort Linear Sort Shell Sort Topological Sort


Linear Srch. or Sequential Srch. Binary Search Breadth First Search Traversal Depth First Search Traversal Shortest Path-Given Source-Destination-Dijkstras


Simple implementation of Hashing Hashing using double-ended Linked List Hashing using Mid-Square Method Example of Hashing n term of the fibonacci series using recursion


Factorial of the given number using recursion Mystery of Towers of Hanoi using recursion


 # include <iostream.h>
 # include <conio.h>

 int binary_search(int [],int,int);

 main( )
       clrscr( );

       const int array_size=10;
       int array[array_size]={0,6,9,12,20,23,29,32,47,79};

       cout<<\" ******************************************************************************\"<<endl;
       cout<<\" *******************************  Binary Search  ******************************\"<<endl;
       cout<<\" ******************************************************************************\"<<endl;

       cout<<\" ******************************************************************************\"<<endl;
       cout<<\" ******************************************************************************\";

       cout<<\"\\n The contents of the array are : \"<<endl;

       cout<<\"\\n     Elements :\"<<\"\\t\\t     Value:\"<<endl;

       for(int count=0;count<array_size;count++)
         cout<<\"\\t\"<<\" array [\"<<count<<\"]\"<<\"\\t\\t\";

       int searching_element=0;
       int flag=0;

       cout<<\"\\n Enter the element you want to find  =  \";


      cout<<\"\\n The given element is found at the position  array[\"<<

      cout<<\"\\n The given element is not found. \";

       getch( );
       return 0;

 /***********************  binary_search(int [],int,int)  *****************/

 int binary_search(int array[],int array_size,int element)
       int start=0;
       int end=array_size-1;
       int middle;
       int position=-1;



         else if(element>array[middle])

       while(start<=end && array[middle]!=element);


       return position;

    Related Post:
  1. Program to read a Non-Linear equation in one variable, then evaluate it using Secant Method and display its kD accurate root

  2. Program to draw a K-Curve of nth order

  3. Program to capitalize the first charcter of every word in a string

  4. Program of Binary Search Tree Operations

  5. Program to draw a line using Bresenhams Line Algorithm (BLA) for lines with slopes negative and greater than 1

  6. Program to add pairs of MxN matrices

  7. Program that computes and display the square of first ten integers. (using for loop)

  8. Program that are completely portable across different operating systems

  9. Program to estimate the value of Fourth Derivative of the function at the given points from the given data using Central Difference Formula of order 2

  10. Program to perform sorting of linklist

  11. Program to computes the product of two matrices of size 4x4 using Strassens Algorithm (Improved Divide and Conquer Strategy)

  12. Program to copy n number of characters from one string to another at position p

  13. Program to compute nCr

  14. Program that takes input of vector elements and performs multiplication operation, and input/output (&gt;&gt;, &lt;&lt;) using operator overloading

  15. Program to illustrate the difference b/w passing the whole array and the single array element as a parameter to a function

  16. Program of heap sort

  17. Program of disk editor

  18. Program that reads a number and displays it with its digits in reverse order using do-while loop

  19. Program to illustrate pointers and an array of structure

  20. Program to fill a Circle using Scan-Line Circle Fill Algorithm

Didn't find what you were looking for? Find more on Program to search an element in an array using Binary search