The other person has a great answer. Here's another approach.
Let's say we're selecting 2 people to fill slots A and B.
Slot A has 10 choices and slot B has 9 choices (since we can't pick the same person again to fill both slots simultaneously).
We have 10*9 = 90 ways to do this if order mattered.
However, we don't care about the order so we actually have 90/2 = 45 ways
---------------------------
Put another way: we can form a table that has 10 rows and 10 columns.
This table has 10*10 = 100 cells inside it.
Cross off the main diagonal that runs from the upper left corner to the bottom right corner. Any of these cells represent a certain person handshaking with themself, which we don't consider.
We cross of 10 items along this diagonal so we have 100-10 = 90 cells leftover.
Now consider that person A shaking with B can be notated as AB. This is identical to BA because the order doesn't matter. So we have twice as many handshakes counted.
That's why we divide by 2 to go from 90 to 90/2 = 45
-----------------------------
Another way to find the answer is to use the nCr combination formula with n = 10 and r = 2.
Yet another way to find the answer is look at Pascal's triangle. Find the row that has 1,10,45... in it at the start. These values correspond to r = 0, 1 and 2 respectively. We can see that 45 is when r = 2, which means we have 2 people shaking hands and there are 45 ways to have ten people shake hands.
So there are many approaches you can take with this problem.