I always thought of crocodiles as simple carnivores but there's evidence that they consume fruit as well.
As explained in Jon Tennant's blog:
A recent review study shows that for crocs, almost a quarter of the fruits consumed were of the 'fleshy' kind (think James and the Giant Peach, but with reptiles). However, none of the recordings were of direct observations of fruit eating, so exactly how or why they did is still a bit of a mystery.
The question of how is mostly a case of speculation, as it's rare to directly observe a croc consuming fruit. Generally, it might be that there is no common reason, and it's a series of partial consumption hypotheses that all just depend on the scenario a hunting croc is involved in. Perhaps they're really good at sneaking up on and gobbling animals preoccupied with nomming fruits, which just happen to get caught up in the act in an apple-goat smoothie of sorts. The yucky extension of this is that the fruit has already been eaten, and gets transferred during the gulping process. Alternatively, it could be a case of mistaken identity, where a sleepy croc might mistake a floating fruit for some sort of tasty nosh...
Perhaps this odd phenomenon might help in part to explain why crocodiles are such successful animals. If food of the meaty sort was ever in short supply, they had the capacity to diversify and track down other food sources, from vegetation and grasses, to getting their 5-a-day.
Read more at his blog.