Is it mandatory for non muslims to wear a skull cap when they enter a mosque for visiting and during namaz to join the namaz service.
I guess you refer to something like this?
Well a cap is not necessary to enter a mosque it is even not mandatory -for a Muslim (men)- to pray, but it is recommended. I've even know that (at least some) tablighis spread ahadith (plural of hadith, prophetic traditions) who strongly recommend having a head cover for men and practice this, but most of these narrations have weaknesses.
The strongest argument for doing or practicing this however is what one may call good taste and to show some kind of respect for your creator in front of whom you are going to pray and whom's "House (of worship)" you are visiting...
On the whole there are many questions already on the site on that topic which you might check:
- Is it obligatory for Muslim men to cover their heads while praying?
- What is a reliable reference for "covering of the head during salah or otherwise is mubah" by men?
- Headcovering For Men in Islam - Required?
And somewhat relevant (parts of my answer on): Was Quran 24:31 changed? "...believing women ... should draw their khimar over their breasts..."
The most important thing if you go to pray in a mosque is that you cover your 'awrah, this means for a men you should wear at least something that covers the body between the knees and naval, however covering your shoulders etc. is strongly recommended based on ahadith.