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