There are 30 total people in the gym.
Use this proportion:
40 12
------- = --------
100 x
40% is the same thing as 40/100 which can be simplified to 2/5.
2 12
------ = ------
5 x
2 x 6=12
Since you multiply 2 by 6 to get 12 you have to do the same thing for 5. ----> 5x6=30
2 12
------ = ------
5 30
There you go! There are 30 total people in the gym. Thats your answer.
Hope this helps! :)