First go to the home menu of your 3DS and click the orange face icon which will take you to your 'Friend List'. Then click on the upper right hand corner and it will ask you to add a friend via Locally or over the Internet.
For Locally: You need to have a friend close to you so you can add each other to your friend list. You and your friend have to click 'Local' and put both of your 3DS(es) close to each other. You and your friend's 3DS(es) will automatically add each one of you to their Friend List.
Via the Internet After you have clicked on 'Internet' it will take you to a screen which will ask you to add a person's Friend Code (FC). Put the person's FC you want to add and make sure that person also added your FC or it won't work. You can check your own FC by looking up at your little Mii profile on the 'Friend List'.
After you have added your friend to your friend list, you can now play Pokemon X/Y together.