New to ubuntu? just stumbled upon installing gcc compiler and running a sample program? It's simple!
open up a terminal and write the command:
sudo aptitude install build-essential
It will automatically install gcc/g++ compiler into your system. Also you can do the same thing from the Synaptic package manager. Open the Synaptic package manager, search for a package "gcc" and then you will get the list of available packages. Just select g++ from there and install. Done !
To test it, write a simple C code like this and name it test.c:
to compile it:
g++ -lm -o test.o test.c
here -lm indicates that the compiler may invoke the math library. test.o is the name of the object file.
finally, you can get the output by executing the object file:
Here you can find details of the build-essential package: