Is it possible for only a part of the HD of my MacBook to not work properly? My MacBook suddenly crashed yesterday. On startup, the computer would always shut down after a few seconds. I used ⌘ Command R to go into Disk Utility from Recovery HD to see what the problem was and the partition with OS X (Yosemite) could not be verified. I have 2 partitions one named BOOTCAMP (for Windows) and the other Macintosh HD (for OS X). The Windows partition was working properly. 

On clicking repair for Macintosh HD I got a message saying the disk could not be repaired due to "error code 8". I formatted the disk and tried to reinstall the OS but I got an error saying that "file system verify or repair failed". 

I was told that a possible solution is to go to single-user mode and type fsck -fy as that repairs the disk. I did that and there were no problems detected however I still could not install the OS and I was getting the same error. I then went back to Disk Utility and removed the Macintosh HD partition. I thought that since the BOOTCAMP partition was working I could try splitting the Macintosh HD partition into smaller partitions and see if there was an error in them.

I split the available free space into 4 smaller partitions and verified each of them; only one of them had a problem. The others were working perfectly. I then played around with the partitions and I now have a partition of around 250 GB that works properly with Yosemite installed and a chunk of free space (that was previously occupied by the partitions that was not working) and the partition for BOOTCAMP (Windows).

So I solved the problem I was initially facing but my question is will this affect my MacBook or my data negatively in any way? Also was the problem caused because of a hard disk failure?
Typically, if you have a spinning hard disk drive (not an SSD or Solid State Drive) and there is a physical problem with the drive, you will get the symptoms you have described. So the first answer to your question is: yes, it is possible for only one part of a hard drive to malfunction. This has been, for me, the more frequent kind of problem, often accompanied by clicks or repetitive noises emanating from the drive itself. This may appear in the OS as one or more unreadable files (if they are in a document or user file), stuttering performance (depending on how unreadable the media is), or strange behavior by the OS (if a system file is located on a damaged portion of the disk). 

You should back up all of your data immediately. Your disk is failing and is no longer reliable. Typically, a disk with a physical continues to accumulate physical faults. Drives get more bad sectors over time, not fewer.