C is not an interpreted language like Python or Perl. You cannot simply type C code and then tell the shell to execute the file. You need to compile the C file with a C compiler like gcc then execute the binary file it outputs.

For example, running gcc file.c will output a binary file with the name a.out. You can then tell the shell to execute the binary file by specifying the files full path ./a.out.

Edit:
As some comments and other answers have stated, there are some C interpreters that exist. However, I would argue that C compilers are more popular.

Answer from Peschke on Stack Exchange
Discussions

How do I run my C program in Mac Terminal?
To compile a file make sure you are in the directory of the file first: cd directory/path/to/file Then to compile the code, use this: gcc filename.c -o executablename To run the app from the terminal ./executablename More on reddit.com
🌐 r/learnprogramming
11
13
July 1, 2013
How Do I Start Programming in C on a Linux Machine That Runs on Arch?
I use vim + gcc, I just go off of compiler errors and warnings that's usually enough for me More on reddit.com
🌐 r/C_Programming
53
0
November 8, 2024
How to run C in windows
This is not a language problem, rather an IDE problem. I know VSCode has pretty bad support for C, and Visual Studio is quite massive, so that probably wouldn't work. Code::Blocks is a very lightweight IDE for C and C++, you could try that. More on reddit.com
🌐 r/C_Programming
22
1
August 19, 2021
How to run c++ files in the command line?
You need to compile first. For single-file compilation, you can use the command g++ -Wall your_source_file.cpp -o name_of_the_exe (if you are on Windows, add .exe to the output name). You can also pass in multiple source files (header files not needed) in a single command (e.g: g++ -Wall mylib.cpp main.cpp -o my_program.exe), but it is time consuming if you have many files. Thus, for more realistic projects, usually you need to setup a build system. It may be Make if it is simple, or CMake/Meson if you want a full-fledged build system. In that case, you need to invoke the commands corresponding to your build system. After you have compiled the program, type its name to the terminal to run it. Here is how I do it on Linux: https://i.imgur.com/g8hvQCk.png , you don't need the ./ if you are using cmd. Note: The -Wall is not required, but is strongly recommended, it is for enabling warnings. Usually when your code has warnings, there is something wrong with it, so try to understand and fix it properly* even when warnings do not prevent you from successfully compiling your program. * Mindlessly fixing warnings is more harmful than not fixing them. You may alter the program behavior when you try to get rid of the warnings without thinking about the code meaning. More on reddit.com
🌐 r/cpp_questions
13
5
April 18, 2021
People also ask

What Does the -static Flag Do When Compiling a C Program?
A: The -static flag compiles the program with static linking, including all library dependencies within the executable.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › how to compile a c program in linux
How to Compile and Run a C Program in Linux Terminal
How Can You Include Debugging Symbols in a Compiled C Program?
A: Compile the program with the -g flag to include debugging information, facilitating source-level debugging.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › how to compile a c program in linux
How to Compile and Run a C Program in Linux Terminal
How Do You Generate Assembly Code from a C Source File?
A: Use the -S flag with GCC to compile the C source file into an assembly language file for examination.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › how to compile a c program in linux
How to Compile and Run a C Program in Linux Terminal
🌐
GeeksforGeeks
geeksforgeeks.org › techtips › how-to-compile-and-run-c-program-in-terminal
How to Compile and Run C program in Terminal - GeeksforGeeks
December 5, 2025 - ... If MinGW is installed correctly, the GCC version will appear. Use the cd command to go to the folder containing your .c file · Type "cd C:\MyPrograms" , Click Enter button. ... Your C program output will now appear in the terminal.
🌐
Tildesites
tildesites.bowdoin.edu › ~ltoma › teaching › cs3225-GIS › fall16 › Lectures › basics.html
Compiling and running a C program from the terminal
bid19628:~ ltoma$ cd Desktop/ bid19628:Desktop ltoma$ mkdir local-cs3225 bid19628:Desktop ltoma$ cd local-cs3225 bid19628:local-cs3225 ltoma$ mkdir startup/ bid19628:startup ltoma$cd startup Now you should see a new empty folder called local-cs3225 on the Desktop. Start "Aquamacs" or "Xemacs". Start typing your code. Save this program as "~/Desktop/local-cs3225/startup/hello.c". Compile and run as above. At the end, you'll want to copy your files to dover.
🌐
Edureka
edureka.co › blog › how-to-compile-c-program-in-command-prompt
How to Compile & Run a C Program in Command Prompt?
July 23, 2024 - To compile and run your C program from the terminal without any problems, simply type hello.exe on a regular command prompt in a Windows environment or in a unix-like one, use the command ./hello.exe.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › how to compile a c program in linux
How to Compile and Run a C Program in Linux Terminal
August 29, 2025 - Before compiling and running a C program, you need to write the source code in a .c file. Linux does not come with a built-in code editor, but you can use any text editor like Nano, Vim, or VS Code. This section guides you through creating a simple C program and understanding its basic structure. To start, open the terminal ...
Find elsewhere
🌐
It's FOSS
itsfoss.com › run-c-program-linux
How to Run C Program in Ubuntu Linux [Terminal & GUI Ways]
March 29, 2023 - Running it in a code editor like Visual Studio Code is even easier. Learn both methods. ... How do you program in C on Linux? It is indeed very easy and consists of three simple steps. Step 1: Write your program and save the file with a .c extension. For example, my_program.c. Step 2: You compile the program and generate the object file using gcc compiler in a terminal like this: ... This was just a quick summary of how to compile and run a C program in Linux.
🌐
VITUX
vitux.com › how-to-write-and-run-a-c-program-in-linux
How to Write and Run a C Program in Linux – VITUX
April 20, 2023 - Enter the following command as root in your Linux Terminal: ... You will be asked to enter the root password; the installation will begin after that. Please make sure that you are connected to the internet. After installing the essential packages, let us write a simple C program. Open Ubuntu’s graphical Text Editor and write or copy the following sample program into it: #include<stdio.h> int main() { printf("\nA sample C program\n\n"); return 0; } Then save the file with .c extension.
🌐
Quora
quora.com › How-do-I-run-a-c-file-in-a-terminal
How to run a .c file in a terminal - Quora
Answer (1 of 3): You compile it using a C compiler. Assuming the .c file is syntactically correct, and you have the libraries needed to link the program into an executable, the compiler will create an executable for you. The name of the executable will be the result of an option specified to the...
🌐
Ruc
webhotel4.ruc.dk › ~keld › teaching › CAN_e14 › Readings › How to Compile and Run a C Program on Ubuntu Linux.pdf pdf
1 How to Compile and Run a C Program on Ubuntu Linux Keld Helsgaun
Search for the terminal application in the Dash tool (located as the topmost item in the · Launcher). Open up a terminal by clicking on the icon.
🌐
Christopher Siu
users.csc.calpoly.edu › ~phatalsk › references › howToCompileAndRunCProgramsFromCommandLine.html
How To Compile and Run C Programs From the Command Line
For example, assumming you have mySource1.c, mySource2.c, and mySource3.c, the command to compile them into a single program would be: gcc -ansi pedantic -Wall -Werror -lm mySource1.c mySource2.c mySource3.c · If you have compiler errors you must fix them now. See How To Fix Compiler Errors to do so and then go back to Step 4, otherwise continue to the next section on how to run your program.To run:
🌐
San Diego State University
ost.sdsu.edu › osticket › kb › faq.php
Run a C Program in Linux
By default, gcc places the executable into this file, overwriting any existing file of the same name. You specify the name of your executable, say samplePrgoram by the following line: gcc sampleProgram.c -o sampleProgram · The final step is to run the compiled C program.
🌐
Wikihow
wikihow.com › computers and electronics › operating systems › windows › simple ways to run c program in command prompt
How to Run a C Program Using Developer Command Prompt
March 25, 2025 - Type “cl” followed by the filename of your C program and press Enter. Type the executable name and press Enter to run the program.
🌐
Unstop
unstop.com › home › blog › how to run c program | step-by-step guide + detailed examples
How To Run C Program | Step-by-Step Guide + Detailed Examples
September 16, 2024 - Create a file in a folder of your choice with the extension .c. Here the previous program is used. Under the play button on the right top corner of the screen, select run C/C++ file. Then make sure to select the compiler.
🌐
Learn C++
learncplusplus.org › home › c++ › how to run a c program in terminal
How To Run A C Program In Terminal - Learn C++
September 3, 2022 - Generally gcc compiler is used as a C compiler and g++ compiler is used as C++ compiler. If your c program file is myapp.c you can compile this with gcc command as below, Be sure that you have permission to write to folder there. Now you can easily run your myapp.out as given below, Here is the full input and output process in Linux terminal
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › build › walkthrough-compile-a-c-program-on-the-command-line
Compile a C Program on the Command Line | Microsoft Learn
In the developer command prompt window, enter cd c:\ to change the current working directory to the root of your C: drive. Next, enter md c:\hello to create a directory, and then enter cd c:\hello to change to that directory.
🌐
Scaler
scaler.com › home › topics › how to run c program in ubuntu
How to Run C Program in Ubuntu? | Scaler Topics
May 4, 2023 - Compile the hello.c program file using gcc hello.c -o hello command in the terminal. It will generate a hello executable file in the same directory. Run the hello executable file in the terminal using the ./hello command.