For the function to be continuous at x=0:
limx→0f(x)=f(0)=K
Finding the limit as x approaches 0:
limx→0(xsin2x+cosx)
=limx→0xsin2x+limx→0cosx
For limx→0xsin2x:
xsin2x=2x2sin2x
=2⋅2xsin2x
Using limu→0usinu=1 where u=2x:
limx→0xsin2x=2×1
=2
For limx→0cosx:
limx→0cosx=cos(0)
=1
Combining the results:
limx→0f(x)=2+1
=3
Since the function is continuous at x=0:
K=3