CodeSutraHub

Installing C

To write a C program, we need a text editor and a compiler to run it. There are many editors available to write C programs. These editors provide a single platform to write, compile, and run C programs. For example, Visual Studio Code, Code::Blocks, etc. You can download and install any editor that suits you. In this section, we will learn how to download Code::Blocks, install it, and run a C program using it.

C Program in Code::Blocks — Download, Install, Run

On this page, you will learn step-by-step how to download Code::Blocks, install it, set up the compiler, write your first C program, compile it, and run it successfully.

Prerequisites

  • Windows 10/11: Must be able to install with admin privileges.
  • Internet: Required to download the Code::Blocks setup.
  • Space: About 300MB of free disk space.

Tip: Choose the Code::Blocks version bundled with MinGW. It includes the GCC compiler automatically, making setup faster and easier.

Download Code::Blocks

  1. Go to the official website and open the Download section.
  2. Select the version named codeblocks-XX-setup.exe (mingw). This version includes the GNU GCC compiler.
  3. Download the setup file and save it in your Downloads folder.

Note: If you choose the without mingw version, you will need to install GCC separately using MinGW or MSYS2.

Install Code::Blocks

  1. Double-click on codeblocks-XX-mingw-setup.exe.
  2. In the setup wizard, click Next → I Agree → Next.
  3. Make sure MinGW Compiler is selected in the components list.
  4. Choose the installation location and click Install.
  5. After installation, check Launch Code::Blocks and click Finish.

Done: Code::Blocks will open. On first launch, if prompted to select the default compiler GNU GCC Compiler, click Yes.

Compiler Setup (if required)

  1. Menu: Settings → Compiler... → Selected compiler: GNU GCC Compiler.
  2. In the Toolchain executables tab, check that paths for gcc.exe, g++.exe, and make.exe are auto-detected.
  3. If not detected, click Auto-detect. If the issue persists, manually set the MinGW installation path.

Common error: “No compiler found.” Fix this by selecting GNU GCC Compiler and setting the MinGW path correctly.

Create a New Console Project

  1. Select File → New → Project....
  2. Choose Console application and click Go.
  3. Select C as the language → Next.
  4. Enter a Project title (e.g., FirstCProgram), choose a folder location → Next → Finish.

Tip: Code::Blocks automatically creates a main.c file. This is where you write your first C program.

Write Your First C Program

Open Sources → main.c in the project tree and paste the following code:


#include <stdio.h>

int main() {
   printf("Hello, Welcome to C World\n");
   return 0;
}
        

Save: Press Ctrl + S to save the file.

Compile and Run

  1. Click Build → Build (or press F9). If there are no errors, proceed to the next step.
  2. Click Run → Run (or press Ctrl + F10).
  3. In the console window, you will see: Hello, Welcome to C World

Fast Shortcuts

  • Build: F9
  • Run: Ctrl + F10
  • Save: Ctrl + S
  • Toggle comment: Ctrl + Shift + C

FAQ

Should I choose the MinGW version?

Yes. For beginners, the MinGW bundled version is best because GCC is ready immediately.

What is a Console Application?

It is an application that displays input and output in the command line (black window). This is ideal for learning programming in the beginning.

Code::Blocks on macOS / Ubuntu?

It is possible, but GCC/Clang setup is different. If you want, I can also provide steps for Linux or macOS.

So far, we have learned:

  • Downloading and installing CodeBlocks
  • Creating a project in CodeBlocks
  • Running the first C program
In the next topic, we will learn about C Variables and Data Types.

Below video explains how to download, install Code::Blocks and run a C program