tanx = 1/2

But we know that :

tanx = sinx/cosx = 1/2

==> 2sinx = cosx..........(1)

Also , we know that:

sin^2 x + cos^2 x = 1

==> cos x = sqrt(1-sin^2 x)..........(2)

Now substitute in (1)

==> 2sin x = sqrt(1-sin^2 x)

Square both sides:

==> 4sin^2 x = 1-sin^2 x

==> 5sin^2 x = 1

Divide by 5

==> sin^2 x = 1/5

==> sin x= 1/sqrt5= sqrt5/5

==> **sin x = sqrt5/5**

Now substitute in (1):

cosx = 2sinx

= 2(sqrt5/5)

= 2sqrt4/5

==> **cos x = 2sqrt5/5**