This is a simple tutorial about how to compile c/c++ program in linux terminal. All linux based operating system comes with c and c++ compiler. if you have installed any distribution like ubuntu,fedora,centOs etc then you can install these compiler from respective software installer. like in ubuntu/debian you can install by following command.

#sudo apt-get install gcc

#sudo apt-get install g++

On Fedora or centOs:

# yum groupinstall 'Development Tools'

How to Compile and Run C program on Linux Terminal

Create a fileĀ  main.c using a text editor such as vi:

To compile above program type below command:

To run executable main:

#./main

How to Compile and Run C++ program on Linux Terminal

Create a fileĀ  main.cpp using a text editor such as vi:

To compile above program type below command:

To run executable main:

#./main