I am thinking of doing cpu mining in the background when users are on my website. Also I am thinking of building a program which does everything in the background(cpu mining), that users can download and run. How much percentage of cpu should i mine for the users to not experience any glitches on their computer? I know it should also depend on the cpu power of the machine but what would be the average percentage that I should take over for this purpose?
First of all, I would recommend that your users are informed that you will be doing CPU mining in the background while they browse your site, and that they agree to let you do this.
Secondly, you should not be CPU mining Bitcoin or any altcoin for which GPU mining or ASIC mining exists. CPU mining is much more inefficient than GPU miners or ASIC miners so you both won't earn much even with thousands of users, and potentially cause irreparable damage to your users' computers.
The best way to find the optimal percentage is to try it out yourself. Write your website software and other software and test it locally on your computer. Adjust it so that the parameters are what you are comfortable with. Keep in mind that the computer's cooling solution will need to work harder and the additional fan noise may not be acceptable to everyone. Once you find something that you are comfortable with (i.e. slowdown in other tasks is acceptable, CPU fan noise is acceptable, etc.), undercut that percentage by a bit.