You can in fact do it without OpenCV. Calculating the average over 4 pixels is not that hard of a task. But, using an OpenCV function might be more convenient and the performance might be better than that of your code (depending on how well you optimized your own code). OpenCV is pretty well optimized in many cases.
Using the corresponding OpenCV function is easy. The OpenCV documentation contains the following example:
resize (src, dst, Size(), 0.5, 0.5, interpolation);
Note that the Size() argument is being ignored, as the size of the destination image is being calculated from the source image and the two scale factors.
As value of the interpolation argument you want to choose INTER_AREA, which does the averaging. Note, however that if you want to solve a more general case in which the scale factor varies over a range, other interpolation modes like INTER_LINEAR or INTER_CUBIC might give better results.
If this is homework, I would suggest that you also write your own version of that function. It is a really good exercise for the basics in image processing. Hope this little hint here gets you started on the right path.