i want to know if i can flash a custom ROM without unlocking the bootloader if this impossible then what happens to the phone if i do that? Thanks.
Generally speaking, you can't. A locked bootloader prevents flashing.
On some devices you might be able to gain root temporarily while the device is running, and could "live" flash a ROM. Some bootloaders will refuse to boot the device at all at that point, whereas others will let you proceed after trying and failing to restore the original. (Or, if you didn't remove the backup image, the restore will succeed.)
The best advice is to avoid attempting any of this with a locked bootloader, unless you want an expensive paperweight.