Tuesday, November 29, 2016

Compile and Run C/C++ Program in Linux/Ubuntu

Last Update:

Recommended Cloud & Hosting: Cloudways, Hostinger & BlueHost
Compiling and running C/C++ is very easy in Linux/Ubuntu without installing any compiler. But to use before gcc for C and g++ must have to installed on your operating system, otherwise your program code will not be compiled. If you don't install this, please install GCC and G++ before using compilation and then follow the below step by step to compile c/c++ in Linux.
Compile and Run C/C++ Program in Linux/Ubuntu

Compile C in Linux/Ubuntu


Step-1: Open Terminal by Ctrl + Alt + T
 
Step-2: Command the below line to create New C File:
gedit filename.c
Here filename.c is the name of c program file with extension.

Step-3: Save the file by Ctrl + S and exit from gedit.

Step-4: Command the below line to create object file:
gcc filename.c ­o filename
Step-5: Command the below line to run your C file:
./filename

Compile C++ in Linux/Ubuntu

Step-1: Open Terminal by Ctrl + Alt + T
 
Step-1: Command the below line to create New C++ File:
gedit filename.cpp
Here filename.cpp is the name of C++ program file with extension.

Step-3: Save the file by Ctrl + S and exit from gedit.

Step-4: Command the below line to create object file:
g++ filename.cpp ­o filename
Step-5: Command the below line to run your C++ file:
./filename

If it has helped you, don't feel hesitate to comment. Happy Coding !

You can compile C/C++ on Sublime Text.

About me


Elliyas Ahmed
Elliyas Ahmed

Hi, I am Elliyas Ahmed, the founder of ComProMath. I try to share what I learn.

Work With Me - SEO Expert, WordPress, Blogger Theme Developer on Fiverr

Lets Disucss on this Article

Don't try SPAMMING here! Submit your Feedback, Questions or Comment related to this Article. Read our Comment Policy.

No comments:

Submit your COMMENT here