Let us assume the common ratio to be = x
Then
7x + 8x = 45
15x = 45
x = 45/15
= 3
Then the two numbers are
7x :8x
7 * 3:8 * 3
21: 24
Then the two numbers are 21 and 24. I hope the procedure in which the problem is done is clear to you. This is a simple but effective way of solving such problems. In future this method will make you confident about solving these kind of problems.