Tutorials Logic, IN +91 8092939553 info@tutorialslogic.com
FAQs Support
Navigation
Home About Us Contact Us Blogs FAQs
Tutorials
All Tutorials
Services
Academic Projects Resume Writing Interview Questions Website Development
Compiler Tutorials

Getting Started with C

What is C?

C is a general-purpose, procedural programming language developed by Dennis Ritchie in 1972 at Bell Labs. It was originally designed to write the UNIX operating system. C is often called the "mother of all languages" because many modern languages — including C++, Java, Python, and PHP — are influenced by its syntax and concepts.

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:

PlatformInstallationVerify
WindowsInstall MinGW-w64 or use VS Code with C extensiongcc --version
Linux (Ubuntu/Debian)sudo apt update && sudo apt install gccgcc --version
macOSxcode-select --install or brew install gccgcc --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 statementreturn 0; signals successful execution
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:

StepCommandDescription
Compilegcc hello.c -o helloCompiles hello.c and creates executable named hello
Run (Linux/Mac)./helloRuns the compiled program
Run (Windows)hello.exeRuns the compiled program on Windows
Compile with warningsgcc -Wall hello.c -o helloEnables all compiler warnings (recommended)
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
    int year = 1972;  // year C was created
    printf("C was created in %d\n", year);

    /* You can also use multi-line comments inline */
    printf("By Dennis Ritchie at Bell Labs\n");

    return 0;
}

/*
Output:
Welcome to C Programming!
C was created in 1972
By Dennis Ritchie at Bell Labs
*/

Ready to Level Up Your Skills?

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