It is possible and in C / C ++, but in a very truncated form - almost no libraries. Only the BIOS functions ( int 13h ) are at your service (Ie, your "Hello, world" should not be displayed either using puts or printf , much less in cout ). No main as an input point (unless you change the runtime loader accordingly). Those. only some basic things (like arithmetic :)) that are compiled into .obj , and linked with a bootloader in an assembler. Once, for the sake of interest, I shortened Turbo C ++ to such a state - nothing even worked out :)
I used TASM in due time - perfectly suited for such purposes.
This code starts working in real mode, so only 16 bits, and (what about PC?), It is loaded into memory at address 0000:7С00 and starts to run from there. It is loaded from the MBR, so if it is something more or less large, then it should immediately count and load the rest into memory. Consider that the DOS com-file, only no org 100h - what is received, is simply put into a very specific :) memory - both on the disk and in RAM, and control is transferred to the first byte.
Accordingly, what is the name of the program here ... The name (file) is already a file system, and here it does not smell like it.
My advice: a virtual machine with a virtual floppy disk drive :), loading from such a virtual floppy disk. The first sector is yours. This will allow you to do what you want without risking anything, and it is very easy to write your creation to a file without having to worry about writing to specific sectors on a disk / flash drive (and you can easily mess things up).