For c-3po, it was a costume, Anthony Daniels played c-3po:
For R2-D2, It was a costume and a remote controlled robot. CGI was also used in the prequel trilogy. So, they had Kenny Baker to play him :
And from Portrayal section of wookieepedia article on R2-D2 :
Baker performed the role of R2-D2 inside a standing unit of the droid, wearing a specially-made suit and manipulating the droid's lights and appendages, turning his head, rocking his body back and forth, and moving his eye with a rod. In addition to Baker's unit, every Star Wars film has made use of a number of remote control units, as Baker's was largely immobile.
A computer-generated R2-D2 was also used in many scenes of the prequel trilogy, including a scene in Episode II where the character walks up a staircase. Baker has stated that he would never have been able to do that in his costume.