Shuffling a deck of playing cards

To shuffle a deck of cards, cut it into two roughly equal stacks. Hold each stack lengthwise between your thumb and middle & ring fingers. Squeeze, putting your index finger against the backs of the cards so that they bow outward. Put your thumbs near each other and slowly slip them off the cards, so that the cards slap against the table a few at a time. Do this with the two stacks overlapping, so that they get mixed together. Square up the stacks and push them together. Repeat.

Bridging the cards is an optional advanced maneuver to bend the cards back in the other direction after shuffling. To bridge the cards, shuffle them but don't square up the deck. Instead put your fingers under the deck and your thumbs on top. Push the cards together so that they bend the other way. They should then riffle together. This keeps the cards straight and looks, sounds, and feels cool.

The above is known as the riffle shuffle. There is also the overhand shuffle, in which you take the bottom two-thirds of the deck and toss a few cards at a time off the top of it onto the former top third of the deck until the stack is exhausted.

Shuffling an array

/* randomizes the order of the first */
/* n elements of an integer array    */
void shuffle(int *array, int n){
  int i, r, temp;
  for(i = n-1; i > 1; --i){
    r = rand()%i;
    temp = array[r];
    array[r] = array[i];
    array[i] = temp;
  }
}