Let the number of right answers and wrong answers be x and y respectively.
According to the question,
3x - y = 40 ... (i)
4x - 2y = 50
⇒ 2x - y = 25 ... (ii)
Subtracting equation (ii) from equation (i), we get
3x - y -(2x - y) = 40 -25
⇒ 3x - y -2x + y = 15
⇒ x = 15 ... (iii)
Putting this value in equation (ii), we get
2(15) - y = 25
⇒ 30 - y = 25
⇒ y = 5
Therefore, number of right answers is x = 15 and number of wrong answers is y = 5
Total number of questions is x + y = 15 + 5 = 20.