It is narrated from Hazrat Jundub (may Allah be pleased with him) that the Noble Prophet (peace and blessings be upon him) said: Whoever does any deed to gain fame, Allah will make (his true intention) heard by people, and whoever does any deed for show (ostentation), Allah will display his showing off to people.
Hadith Referenceمسند احمد / تتمہ مُسْنَدِ الْكُوفِيِّينَ / 18808