Hanoi Tower

The formula : To move n plates, you have to move at least (2ˆn – 1) times

Recursion

Factorial

int fact(int n)
{
if(n == 0)
return (1);
else
return (n * fact(n-1));
}

Useful Function

#include <string> strrev( ) // To reverse a string
♦ ♦ ♦ ♦ ♦ ♦ ♦ ♦ ♦ ♦ ♦ ♦ ♦ ♦ ♦ ♦ [...]

Sort

Bubble_sort

#include <algorithm>
// bubble_sort(array, 0, ARRAY_SIZE – 1);

void bubble_sort(int ar[], int start, int end)
{
for(int i = end; i > start; i–)
for(int j = start; j < i; j++)
if(ar[j] > [...]

How to post code in wordpress

The way to post code in wordpress is as follows:
wrap your code in the following tags
[sourcecode language='java']…[/sourcecode]
And the presentation would be like this:

// Paste your code here

But be careful /0 won’t be presented and certain symbols will show smileys !!