How to Run C Program
To run a C program, you need a C compiler. GCC is one of the most commonly used C compilers.
Method 1: GCC on Windows
- Install a GCC toolchain such as MinGW-w64.
- After installation, make sure the compiler’s bin folder is available in PATH.
- Open Command Prompt.
- Type the following command:
| gcc –version |
- If a GCC version appears, the compiler is ready.
Create and run your first file
| hello.c #include <stdio.h> int main() { |
Save the file as hello.c. Then compile it:
| gcc hello.c -o hello |
Run it. On Windows, the executable is normally hello.exe. On Linux/macOS, you can usually run:
| ./hello |
| OUTPUT Hello, C! |
| ⭐ EASY TIP: An IDE such as Code::Blocks or Visual Studio Code is an editor/development environment. The actual compilation is done by a compiler such as GCC. |