There's a small problem here. First, hex output only applies to integer types (char, short, int, long, and the unsigned versions of those). If you have to display a hexadecimal representation of floating point or string data, you need to write some code.
Second, hex is sticky. One you "output" it to a stream it stays set until you reverse it. This is one of the many unlovely things about cout << for formatted output. To see what I mean, change the value for y from 9 to something bigger, like 42042, and you'll see that it actually displays as a43a, even when you thought you were displaying it in decimal.
Add "<< dec" just before each "<< endl" and you should get y displaying normally.
Third, it appears that pointers are formatted in uppercased hexadecimal with leading zeros no matter what you do. If this is the only thing you needed "hex" for, then you don't need it at all.
Finally, no...there's no "0x" on output. If you want that, you need to add it yourself.