If we know that B is between A and C, and we know AB, BC, and AC then we can assume that AB+BC = AC.
In this case:
AB = 4x+10 , BC = 8x-18 , AC = 40
AB + BC = AC
- (4x+10) + (8x-18) = 40
- 12x - 8 = 40
- 12x = 48
- x = 4
- AB = 4(4) +10 = 26
- BC = AC - AB = 40 - 26 = 14