in the answer key there is a function of cos in place of sin

Yes, you are correct .

According to the condition given, the initial charge is zero, hence at t=0 voltage accross the capacitor must be zero . But putting t=0 in the derived equation V=E/2 . So the ans is not correct . Write cos in place of sin , and it will be justified . Please check your deduction once again .