How do I know what the end products of the reaction of glucose and fructose?
There are three possibilities. The first is knowing the reaction. I.e., you just know because you rote memorised it, that one molecule of water will be lost and then you apply that.

The second is knowing the mechanism. If you take a good look at it, a water molecule must be displaced for the mechanism to work out. Anything else would generate something highly unstable.

And finally, if you know the product structure, you can calculate double bond equivalents. Both reactants have a single double bond equivalent: $(2 \times 6 - 12)/2 + 1 = 1$. This corresponds to the ring in the reactants’ structures. The product has two rings, thus it requires two double bond equivalents. The number of carbons must stay the same, though. Thus: $(2 \times 12 - n)/2 + 1 = 2$; rearranging gives $n = 22$. Two hydrogens must be ejected and that biochemically typically happens with water.