If I recall correctly, the exchange takes place in a busy carnival, with lots of people clamoring for service. O'Neal's character gives him a 5 and asks for a 10 instead. The harried carnival guy thinks 5 ones plus a 5 equals 10.
There was a similiar scam in Twenty Bucks, perpetuated by Steve Buscemi. I forget the exact details, but he buys something small (a cup of coffee?) and pays with a twenty. He then says "wait, I have a smaller bill." It's gets fuzzy in my mind after that, but I think he somehow gets the change for the twenty, as well as exchanging the smaller bill for the twenty.
There was another scam involving a lady cashier. Ryan pays for something with a big bill ($50? $100?). Tatum buys something, gives the cashier a much smaller bill, then claims she gave her the big bill. Tears appear as Tatum claims it was a special bill from her aunt, with her name on it. Of course, it does have her name on it, since Ryan gave it to the cashier. The manager tells the cashier to give Tatum her "special" bill.