The given differential equation dxdy+ytanx=sin2x is linear differential equation of the form
dxdy+P(x)y=Q(x) with P(x)=tanx, Q(x)=sin2x
Now, I.F.=e∫P(x)dx=e∫tanxdx=eln(secx)=secx
And, the solution is y(I.F.)=∫Q(x)(I.F.)dx+c
⇒ysecx=∫secxsin2xdx+c
⇒ysecx=∫cosx1(2sinxcosx)dx+c
⇒ysecx=∫2sinxdx+c
⇒ysecx=−2cosx+c
Given, y(0)=1
⇒1⋅sec0=−2cos0+c
⇒1=−2+c
⇒c=3
⇒ysecx=−2cosx+3
Now, at x=π
y(π)secπ=−2cosπ+3
⇒y(π)(−1)=−2(−1)+3
⇒y(π)=−5.