How To Compile And Run a C/C++ Code In Linux
You can compile and run a C/C++ code in Linux using the following steps:
- Open a terminal window.
- Create a file for your C/C++ code and save it with a
.cor.cppextension, e.g.code.corcode.cpp. - Compile the code using the GCC compiler by running the following command:
gcc code.c -o codeor
g++ code.cpp -o codeNote: The -o option is used to specify the output file name. The default output file name is a.out if the -o option is not specified.
- Run the compiled code by typing:
./code- The output of the code will be displayed on the terminal.
