Here's how it happened:
* Cedric was chosen to face the Hungarian Horntail dragon.
* He didn't initially know how to approach the dragon, and seemed unsure.
* Then, he realized that the dragon was agitated because of a golden egg nearby.
* Cedric calmly approached the egg and, using Parseltongue, spoke to it, calming the dragon down.
* He then grabbed the egg and escaped the dragon's enclosure.
While he did not defeat the dragon like Harry did (who used the dragon's own fire against it), Cedric's calm and intelligent approach allowed him to successfully get past the dangerous creature.