Unlike the letter c, which is an alternate spelling for the sounds of k and s and has no sound of its own, the letter g does have one sound of its own: the “hard” sound heard in glove. The second sound of g, the “soft” sound heard in giant, represents the sound that belongs to the letter j [j].
In English orthography, the pronunciation of hard ⟨g⟩ is /ɡ/ and that of soft ⟨g⟩ is /dʒ/; the French soft ⟨g⟩, /ʒ/, survives in a number of French loanwords (e.g. regime, genre), [ʒ] also sometimes occurs as an allophone of [dʒ] in some accents in certain words.
The key to the soft G is that it sounds like the letter J. This often happens when G is followed by an "e," "i," or "y," and the sound is more gentle. A great way to practice is with words like giraffe, gym and giant, which use this soft G sound!
A heteronym is a homograph that is not a homophone, a word that has a different pronunciation and meaning from another word with the same spelling. Heteronym pronunciation may vary in vowel realisation, in stress pattern, or in other ways.
The letter g in English takes either a “hard g” sound (e.g. girl) or a “soft j” sound (e.g. gibberish). There are numerous examples of this. Both g's in ginger have soft j sound.
It's a voiced palato-alveolar sibilant affricate. So in one sense, you're not pronouncing the /g/ at all in “longevity,” but in the sense that the grapheme “g” is used to represent both the /ŋ/ and the /dʒ/ astounds, you are pronouncing the g twice.
However, silent ⟨k⟩ and ⟨g⟩ occur because of apheresis, the dropping of the initial sound of a word. These sounds used to be pronounced in Old and Middle English.
The words giant, stage and gym all contain the soft g sound. In these words, g is followed by i, e and y. The word jam is spelt with a j. The /j/ sound is followed by /a/.
Use 'c' when the /k/ sound is followed by 'a', 'o', or 'u' (like in the words cap or cone). Use 'k' when the /k/ sound is followed by 'e', 'i', or 'y' (like in the words kept, kite, or sky).