In trading, if a market order is not fulfilled completely then what happens to remaining unfilled quantity?
In order-driven markets the order goes to the book and will be matched with either the next incoming market or limit order of the opposite side.
The rules for the price when the market order hits another market order are a bit complicated and depends on whether there are limit orders in the book on the side of your market order.
In many markets you can control however what happens. Either by using a different order type: market-to-limit (rest of the order is put as limit order at the price of the last fill) or market-funari (left-overs are posted again as market order in the close auction), or by using a time-in-force setting that specifies what you want: GFT (good-for-time, order will be cancelled after a certain period), GTD (good-till-date, order will be cancelled at a certain date and time), or simply IOC (immediate-or-cancel, the left-overs will simply be cancelled).
In quote driven markets it's completely undefined what happens, the dealer would usually fill your order as a whole or inform you about the problem.