I assume that you are on latest Mac with Xocde 5 or later already installed on your mac from Mac App Store.
SO here is how to write Language C or C++ Program Code on Macintosh OSX using Xcode.
Note: Writing a C or C++ specific code only differs on Step 05 every other step is the same.
Step 01 is to Navigate to ‘Application’ folder & double click on ‘Xcode’ Application
OR Click on ‘Spotlight’ at top left menu bar of your Mac & type ‘Xcode’ press return key on keyboard after getting appropriate search results