I wrote a simple program in C and compiled it using GCC on Ubuntu. Will this file work on another machine?
The a.out (.o) files work on Unix-like OS machines. (Details of OS given above by @Nicholas Wilson)
The .o includes all the libraries that are mentioned in .c file. A copy of the called function is copied from the library and made into .o file along with the code given in .c file.
Again you compile the .o file to get an executable.
Use of .o file is, if you are working on a big project where each department has their own source files (.c) and need to make a single executable. You can get it by compiling the .c files. After compiling you get .o files. Now, you can combine all these .o files to give a single executable.