odolvlobo is correct. To a certain extent it depends on the wallet software you are using. There are a few important points to be aware of though:
You can encounter complications if you spend bitcoins that have not yet confirmed. A transaction uses the hash of the transaction that created the output that you are spending to identify that output. It's possible for the hash of an unconfirmed transaction to change before it becomes confirmed (This is often called "transaction malleability"). If that happens, then the second transaction will no longer be valid, and you'll need to re-send it.
In the example given, if your friend is right there with you, most wallet software will allow you to create a single transaction that has two outputs. The single transaction can send 0.5 BTC to the coffee shop and 0.5 BTC to your friend, and you'll have no change to worry about at all.
The second transaction isn't valid in a block (can't be confirmed) until the first transaction is in a block. Therefore, it isn't possible for the second transaction to be confirmed before the first. They can both be confirmed in the same block (at the same time), or the first transaction can be confirmed and your friend can end up waiting for a later block for his transaction to confirm.
Am sorry , am still learning but i tried my best to answer him
Thank you for clarifying it a bit more for me too
Brilliant, thanks for that very clear explanation. I think I *may* now have understood transaction malleability for the first time as well which is a bonus! I haven't carried out many transactions - and definitely never tried simultaneous transactions - so I had no idea that that sort of functionality was availability in some wallets. Thanks everyone for your input on this. It's can be hard to find definitive answers some times so everyone's help is really appreciated. If people get it wrong, all well and good - then more of us get to learn the right answers