First-principles calculations have been performed to investigate energetics and site preference of carbon (C) in a tungsten (W) 5(310)/[001] grain boundary (GB). We calculate the solution energies of the C atom in the GB, which show that the interstitial C is energetically favored over the substitutional C. The segregation energy is calculated to be 3.95 eV for the energetically favorable GB interstitial site, indicating that C energetically prefers to segregate into the W GB. Based on the Rice-Wang model, our total energy calculations show that C has a significant beneficial effect on the W GB cohesion.