Tutorials Logic, IN info@tutorialslogic.com

C Language Setup Install GCC Run First Program

What is C?

C is a compiled, procedural systems language with explicit types, functions, pointers, arrays, structures, and manual resource management. It gives programs close control over memory layout and operating-system interfaces while requiring careful bounds and lifetime handling.

C is a compiled, statically-typed language that gives programmers direct access to memory through pointers. It is widely used in operating systems, embedded systems, device drivers, and performance-critical applications.

Why Learn C?

  • Foundation of many modern languages (C++, Java, C#, Python)
  • Essential for OS development (Linux kernel is written in C)
  • Critical for embedded systems and microcontrollers
  • Teaches memory management and low-level programming concepts
  • Fast execution - close to hardware performance
  • Widely used in competitive programming and system programming

Setting Up GCC Compiler

GCC (GNU Compiler Collection) is the most popular C compiler. Here's how to install it on different platforms:

Platform Installation Verify
Windows Install MinGW-w64 or use VS Code with C extension gcc --version
Linux (Ubuntu/Debian) sudo apt update && sudo apt install gcc gcc --version
macOS xcode-select --install or brew install gcc gcc --version

Structure of a C Program

Every C program follows a basic structure:

  • Preprocessor Directives - lines starting with #, processed before compilation (e.g., #include <stdio.h>)
  • main() function - the entry point of every C program
  • Statements - instructions ending with a semicolon ;
  • Return statement - return 0; signals successful execution

Hello World - First C Program

Hello World - First C Program
#include <stdio.h>   // preprocessor directive - includes standard I/O library

int main() {          // main function - program starts here
    printf("Hello, World!\n");  // print to console; \n = newline
    return 0;         // return 0 = program ran successfully
}

Compile and Run

To compile and run a C program using GCC:

Step Command Description
Compile gcc hello.c -o hello Compiles hello.c and creates executable named hello
Run (Linux/Mac) ./hello Runs the compiled program
Run (Windows) hello.exe Runs the compiled program on Windows
Compile with warnings gcc -Wall hello.c -o hello Enables all compiler warnings (recommended)

C Program with Comments

C Program with Comments
#include <stdio.h>

/*
 * Multi-line comment
 * This program demonstrates both types of comments in C.
 * Comments are ignored by the compiler.
 */

int main() {
    // Single-line comment: print a greeting
    printf("Welcome to C Programming!\n");

    // Variables and formatted output
    int warnings_enabled = 1;
    printf("Compiler and runtime are working\n");

    /* Use the value in a condition */
    if (warnings_enabled) {
        printf("Next: inspect variables and memory\n");
    }

    return 0;
}

/*
Output:
Welcome to C Programming!
Compiler and runtime are working
Next: inspect variables and memory
*/
Before you move on

C Language Setup Install GCC Run First Program Mastery Check

5 checks
  • C compiles procedural source into a native program for the selected target.
  • Its types, pointers, arrays, and structures expose memory and data-layout decisions.
  • Correct C code must enforce bounds, ownership, initialization, and resource cleanup explicitly.
  • C is a compiled, statically-typed language that gives programmers direct access to memory through pointers.
  • It is widely used in operating systems, embedded systems, device drivers, and performance-critical applications.

Build Failure Boundary

  • Compile and link are separate stages

    A syntax error stops compilation, while an undefined reference is usually a link error. Read the first diagnostic and identify its stage before changing source code.
Next Step
Next Practice

Finish the concept here, then reinforce it with hands-on coding, interview prep, or a tool that matches the topic.

Browse Free Tutorials

Explore 500+ free tutorials across 20+ languages and frameworks.