Now go to the directory ehre ns3 is installed (it is generally extracted in home directory by the name of the downloaded tar file).
Now to run the program type
If you are writing code in (say)filename.cc, then you do not need to add extensions (.cc) with the file name while running the code.
To view the output in visualizer u can type