We know that Sum of all the angles should be 90 degree for it to be complementary.
Let the angles be x and y degrees.
Since the difference is 40 degrees,
x - y = 40 ....(1)
But,
x + y = 90 ....(2) [By the definition of complementary angles]
By eliminating (1) and (2) we get,
x = 25 degrees.
Putting the value of x in eq.(2) we get ,
y = 65 degrees.