//Create folder:
SPDocumentLibrary docLib = myWeb.Lists["Pages"];
SPListItem newFolder = docLib.Items.Add("",SPFileSystemObjectType.Folder,"first folder")
newFolder.Update();
//Create subfolder:
SPDocumentLibrary docLib = GetYourDocumentLibrary("YourSiteName","Pages");
SPListItem newFolder = docLib.Items.Add("http://yoursharepointsite/yoursite/pages/rootfolder",SPFileSystemObjectType.Folder,"sub folder")
newFolder.Update();
Make sure provide full path when create subfolder