A gymnasium was an area of a starship which was dedicated to physical fitness and exercise. The gymnasium on board an NX-class starship was located on C Deck. It usually featured a number of items that could be used for the fitness of the crew, including exercise bikes, treadmills, and weights. (ENT: "Bound", "A Night in Sickbay", "Stigma")
In an hallucination experienced by Ensign Hoshi Sato in 2152, she imagined Enterprise's gym at one point being used for workouts by herself and Commander Charles Tucker III; he used the gyrosphere whereas she used a weight machine. Sato erroneously believed she was in the gym when, following Tucker's departure, she became invisible; the weights in the room were unresponsive to her touch, her right hand even passed through both the free-weights and the control panel for the door out of the gym, and she ultimately watched her reflection in the large mirror fade completely out of sight. She, unable to leave, seemingly remained in the gym overnight and saw T'Pol and Tucker carry out a quick inspection of the area hours later, investigating her disappearance, before she hurriedly followed them out of the room. (ENT: "Vanishing Point")
Later in 2152, Lieutenant Malcolm Reed was cycling on an exercise bike in the gym when Commander Tucker entered the room. He went on an adjacent exercise bike and, as the two men cycled, they discussed Denobulans Phlox and Feezal. (ENT: "Stigma")
Later the same year, Ensign Travis Mayweather, Lieutenant Malcolm Reed and two other officers used Enterprise's gymnasium to train, in an attempt to keep their minds off of three Orion slave girls who were guests aboard Enterprise. (ENT: "Bound")
In 2266, Charles Evans visited the gymnasium of the Constitution-class starship USS Enterprise. While there, he exhibited extremely powerful abilities when he made a laughing Sam disappear. (TOS: "Charlie X")
The gymnasium on board the Galaxy-class starship USS Enterprise-D was located on Deck 12. In addition to gymnastics studios and martial arts areas, (TNG: "The Price", "Clues", "Second Chances") there was also a parrises squares area, (TNG: "Second Chances") a zero gravity area, (TNG: "Encounter at Farpoint") and an anbo-jytsu court. (TNG: "The Icarus Factor") The starship's gymnasium also featured a fencing room, where Captain Jean-Luc Picard often fenced with members of his crew. (TNG: "We'll Always Have Paris", "I Borg")
Later that year, Baxter was exercising in the gymnasium again when he realized that the environmental controls were malfunctioning and the temperature had dropped to below 10 °C. This was discovered to have happened as a result of Voyager's encounter with a spatial distortion. (VOY: "Twisted")
The gym aboard the USS Enterprise was referred to in a story outline for TOS: "The Corbomite Maneuver". In a memo that Matt Jefferies wrote about elements in that story outline and sent to Gene Roddenberry on 12 April 1966, however, Jefferies expressed about the gym, "Time required will be for props." Ultimately, the Enterprise's gym appeared only in TOS: "Charlie X". In that entry, the gym was a redress of the set used as the ship's engineering. A room where gymnasts are shown tumbling, in the same episode, was the redecorated briefing room.
The set used as the Galaxy-class gymnasium in Star Trek: The Next Generation was one of the last sets built for the series and was also used as the cargo bays, shuttlebays and holodecks of the same class. (Star Trek: The Next Generation Companion (3rd ed., p. 10)) As well, the wide corridor outside engineering was redressed for some of the gymnasium sets. (Star Trek Encyclopedia (4th ed., vol. 1, p. 321)) The anbo-jyutsu gymnasium set for "The Icarus Factor" on Paramount Stage 9 was designed by Andrew Neskoromny. 
In Star Trek: Enterprise, the gymnasium was a redress of the launch bay set. The NX-class gym was to have been introduced in the ENT Season 1 episode "Breaking the Ice" but it doesn't actually appear in the final version of that outing. In the first draft of "Breaking the Ice", the area was described: "The small gym is appointed with 22nd century weight machines, a high-tech stationery bike and old standbys like free weights and a punching bag. There's one small window on the back wall with stars outside visible at warp."