C Lesson 3 – Installation and Features | Dataplexa

Installation and Setup of C Programming

Before we write serious C programs, we must prepare our system properly. A good setup removes frustration and lets you focus on learning, not fighting with tools.

In this lesson, I will clearly show you what you need, where to download it, and how C programs actually run on your computer.


What Is Required to Run a C Program?

To write and execute C programs, you need three basic things:

  • A text editor to write code
  • A C compiler to translate code into machine language
  • A terminal or command prompt to run programs

Among these, the most important component is the C compiler.


What Is a Compiler?

A compiler is a program that converts C source code into machine-readable instructions.

C is a compiled language, which means the program must be compiled before it can run. This is one reason why C programs are very fast.


Installing C on Different Operating Systems

Windows Users

Windows does not include a C compiler by default. The easiest and safest way to install one is by using MinGW.

Click the button below to download MinGW:

Download MinGW (Windows)

After installation, make sure the compiler path is added to system environment variables.


Linux Users

Most Linux systems already support GCC. If it is not installed, you can install it using the terminal.


sudo apt install gcc

This command downloads and installs the GCC compiler.


macOS Users

macOS users can install the Xcode Command Line Tools, which include the Clang C compiler.

Click the button below or use the command shown.

Download Xcode Command Line Tools


xcode-select --install

Writing Your First C Program

C programs are saved using the .c file extension. Let us create a simple program named hello.c.


#include <stdio.h>

int main() {
    printf("C is ready to use!");
    return 0;
}

Every C program starts execution from the main() function.


Compiling and Running the Program

Use the following command to compile the program:


gcc hello.c -o hello

If there are no errors, the program is compiled successfully. Now run it using:


./hello

Mini Practice

  • Create a C program that prints your name
  • Compile and run it successfully
  • Change the output message and recompile

Quick Quiz

Q1. What is the purpose of a compiler?

A compiler converts C source code into machine-readable machine code.

Q2. Which file extension is used for C programs?

C programs use the .c file extension.

Q3. Why must C programs be compiled before execution?

Because computers understand only machine code, not C source code.

Q4. Which compiler is commonly used on Linux?

GCC is commonly used on Linux systems.

Q5. What does the -o option do?

It specifies the output executable file name.