Skip to content
Free course Programming Certificate included

C Programming for Beginners

Learn the language behind operating systems, step by step

  • Beginner level
  • 10 hours
  • 13 lessons
  • English
  • By Muninder Singh

What you'll learn

  • Install a free C compiler or use an online compiler, and compile and run programs
  • Use variables, data types, operators and formatted input/output
  • Control program flow with if-else, switch and loops
  • Write and call functions with parameters and return values
  • Work with arrays and strings
  • Understand pointers and how they relate to arrays and functions
  • Group related data with structures
  • Read and write text files, and debug common beginner errors

Course curriculum

4 sections · 13 lessons · 9h 5m

01Getting Started with C 3 lessons
  • What Is C? Setting Up a Free Compiler Free preview35 min

    What is C?

    C is a general-purpose programming language created by Dennis Ritchie at Bell Labs in the early 1970s. It was used to write the UNIX operating system, and today it still powers operating system kernels, embedded devices such as washing machines and routers, databases and compilers for other languages.

    C is called a middle-level language: it is readable like a high-level language but also gives you close control over memory, like a low-level language. That is why it is fast, and why learning it teaches you how computers really work.

    How a C program runs

    C is a compiled language. You write source code in a text file ending in .c. A program called a compiler translates it into a machine-code executable that your computer runs directly.

    1. Write the source code: hello.c
    2. Compile it: the compiler checks for errors and creates an executable (hello.exe on Windows, hello on Linux/macOS)
    3. Run the executable

    If there is a mistake, the compiler shows an error with the line number, and no executable is created until you fix it.

    In this course we use GCC (the GNU Compiler Collection), which is free and works on Windows, Linux and macOS.

    Option 1: An online compiler (no installation)

    If you are on a shared or low-spec computer, start with a free online C compiler. Search for "online C compiler" and pick a well-known one, such as the compilers offered by OnlineGDB, Programiz or similar sites. Type code, click Run, and type any input in the console area. Online compilers are perfect for learning, but avoid pasting private data into them.

    Option 2: Code::Blocks on Windows (easiest install)

    Code::Blocks is a free editor (IDE) for C and C++.

    1. Go to the official site, codeblocks.org, and open Downloads → Binary release.
    2. Download the Windows installer whose name includes mingw-setup. This version includes the GCC compiler. The version without "mingw" has no compiler.
    3. Install with the default options.
    4. Open Code::Blocks, choose File → New → Empty File, type your program, and save it as hello.c. The .c extension matters.
    5. Press F9 (Build and run).

    Option 3: MinGW-w64 with VS Code

    Many programmers prefer Visual Studio Code with a separately installed GCC. On Windows, GCC is commonly installed through MinGW-w64 (for example, via the MSYS2 installer). After installing, add the compiler's bin folder to your system PATH, as described in the installer's documentation. Then check it in Command Prompt:

    gcc --version

    On Linux, install GCC from your package manager (for example, sudo apt install build-essential on Ubuntu or Debian). On macOS, run xcode-select --install, which installs the Clang compiler; the gcc command works and runs Clang.

    Your first C program

    Create a file called hello.c:

    #include <stdio.h>
    
    int main(void)
    {
        printf("Namaste! I am learning C.\n");
        return 0;
    }

    Compile and run it from the terminal (Command Prompt, PowerShell or a Linux/macOS terminal), inside the folder where you saved the file:

    gcc hello.c -o hello
    ./hello

    On Windows Command Prompt, run hello instead of ./hello. Output:

    Namaste! I am learning C.

    You will learn what each line means in the next lesson. For now, notice that:

    • printf prints text, and \n moves to a new line.
    • Every statement ends with a semicolon ;.
    • C is case-sensitive: Printf or MAIN will not work.

    Turn on warnings

    Add -Wall when compiling. It asks GCC to warn you about suspicious code, which catches many beginner bugs early:

    gcc -Wall hello.c -o hello

    A note about Turbo C

    Some older books use Turbo C, with #include <conio.h>, clrscr() and void main(). These are not part of standard C and do not work on modern compilers. This course uses standard C with int main(void), which works everywhere.

    Practice task

    1. Set up a compiler: an online compiler, Code::Blocks, or GCC with VS Code.
    2. Type the hello program yourself (do not copy-paste), compile it and run it.
    3. Change the message to print your name and your city on two separate lines using two printf statements.
    4. Delete one semicolon, compile again and read the error message. Note the line number it reports, then fix the error.
  • Structure of a C Program, printf and scanf Free preview40 min

    Anatomy of a C program

    Let us look closely at a slightly bigger program:

    /* greet.c: asks for an age and prints a message */
    #include <stdio.h>
    
    int main(void)
    {
        int age;
    
        printf("Enter your age: ");
        scanf("%d", &age);
    
        printf("You are %d years old.\n", age);
        printf("In 5 years you will be %d.\n", age + 5);
    
        return 0;
    }

    Sample run (the user types 19):

    Enter your age: 19
    You are 19 years old.
    In 5 years you will be 24.

    Line by line:

    • /* ... */ is a comment. The compiler ignores it. Single-line comments start with //.
    • #include <stdio.h> is a preprocessor directive. It includes the standard input/output header, which declares printf and scanf.
    • int main(void) is the main function. Every C program starts running here. int means it returns a whole number to the operating system.
    • The curly braces { } mark the start and end of the function body.
    • int age; declares a variable called age that holds an integer.
    • return 0; ends main and tells the operating system the program finished successfully.

    printf: printing output

    printf prints a format string. Inside it, format specifiers starting with % are replaced by the values that follow.

    #include <stdio.h>
    
    int main(void)
    {
        int marks = 87;
        float percent = 72.5f;
        char grade = 'B';
    
        printf("Marks: %d\n", marks);
        printf("Percent: %.1f%%\n", percent);
        printf("Grade: %c\n", grade);
        printf("Name: %s\n", "Kavya");
        return 0;
    }

    Output:

    Marks: 87
    Percent: 72.5%
    Grade: B
    Name: Kavya
    SpecifierType
    %dint (whole number)
    %ffloat or double (decimal); %.2f shows 2 decimal places
    %cchar (single character)
    %sstring (text)
    %%prints a percent sign

    Escape sequences

    SequenceMeaning
    \nNew line
    \tTab
    \"Double quote inside a string
    \\Backslash

    scanf: reading input

    scanf reads values typed by the user. It uses the same specifiers, but for float you use %f and for double you use %lf.

    #include <stdio.h>
    
    int main(void)
    {
        int a, b;
    
        printf("Enter two numbers: ");
        scanf("%d %d", &a, &b);
        printf("Sum = %d\n", a + b);
        return 0;
    }

    If the user types 12 30, the output is Sum = 42.

    Why the & sign?

    &a means "the memory address of a". scanf needs to know where to store the value, so you pass the address. Forgetting the & is one of the most common beginner mistakes: the program may crash or print garbage. (Strings are an exception, which you will see later.)

    Reading a single character

    When reading a char after a number, put a space before %c, like scanf(" %c", &ch);. The space skips the leftover Enter key in the input.

    Indentation and style

    C does not care about spaces and new lines, but people do. Indent the code inside braces by four spaces, put one statement per line, and use meaningful names like total_marks instead of x. Your code will be easier to read and debug.

    Common mistakes

    • Missing semicolon at the end of a statement. GCC often reports the error on the next line.
    • Using %d to print a float, or %f to print an int. The output will be wrong. Compile with -Wall and GCC warns you.
    • Forgetting & in scanf.
    • Writing #include <stdio.h> with a typo, so printf is "implicitly declared".

    Practice task

    1. Write a program that asks for the length and breadth of a rectangle (whole numbers) and prints its area and perimeter.
    2. Write a program that asks for a price as a decimal (use float and %f) and prints it with exactly two decimal places using %.2f.
    3. Print a small bill using \t to line up the columns: item name, quantity and price.
    4. Remove the & from one scanf, compile with -Wall, and read the warning GCC gives.
  • Data Types, Variables and Operators 45 min
02Control Flow and Functions 3 lessons
  • Decisions with if, else and switch 40 min
  • Loops: for, while and do-while 45 min
  • Writing Your Own Functions 45 min
03Arrays, Strings and Pointers 3 lessons
  • Arrays 45 min
  • Strings in C 45 min
  • Pointers Basics 50 min
04Structures, Files and Debugging 4 lessons
  • Structures 40 min
  • File Input and Output 45 min
  • Common Beginner Errors and a Mini Project 50 min
  • Final Exam 20 min

About this course

Why learn C?

C is one of the oldest and most influential programming languages still in wide use. Operating systems, embedded devices, databases and parts of many other languages are written in C. Learning it teaches you how a computer really stores data in memory, which makes every language you learn afterwards easier. C is also part of many school, polytechnic, BCA, B.Tech and diploma syllabi, and often appears in technical interviews and entrance tests.

How you will learn

Every lesson has complete, working programs that you can copy, compile and run, followed by a practice task. You will use a free compiler such as GCC (through Code::Blocks or MinGW-w64 on Windows) or a free online C compiler in your browser, so a basic laptop or even a cyber café computer is enough.

What you will build

A simple calculator, a times-table printer, a marks analyser using arrays, string utilities, a student record program using structures, and a mini project that saves records to a file.

Common errors, explained

C can be strict and its error messages can look scary. The course shows the most common beginner mistakes, such as a missing semicolon, a forgotten & in scanf, array index errors and uninitialised variables, and how to fix them.

Requirements

  • Basic computer skills: creating folders, saving files and using a browser
  • A Windows, macOS or Linux computer, or any browser for an online C compiler
  • No programming experience needed

Earn a verifiable certificate

Pass the final online exam (20 minutes, 15 questions, pass mark 40%) to receive your certificate instantly. Each certificate has a unique number and QR code for instant verification.

This is an independent, institute-issued skill-training certificate — not a government-recognised degree or diploma.

Your educator

M

Muninder Singh

Frequently asked questions

Is C a good first programming language?
Yes, if you want a strong foundation. C is stricter than Python, but it teaches how memory and computers work. If you only want quick results for data or automation, Python may feel easier at first; both are good choices.
Which compiler should I use?
The course uses GCC, which is free. On Windows you can install Code::Blocks with its bundled MinGW compiler, or MinGW-w64 with VS Code. On macOS and Linux GCC or Clang is easy to install. You can also start with a free online C compiler in your browser.
Is Turbo C used in this course?
No. Turbo C is very old and does not follow modern C standards. Programs in this course follow standard C and use int main(), which works on GCC, Clang and online compilers.
Will this course help in college exams and interviews?
It covers the core topics found in most beginner C syllabi and interviews: data types, operators, loops, functions, arrays, strings, pointers, structures and files. Always check your own syllabus for extra topics.
Is the certificate free?
Yes. Pass the final exam with 40% or more to download your GCI EDU certificate. It is an independent skill-training certificate, not a government qualification.

Have a question about this course?

Leave your details and our team will get back to you, usually within one working day.

Share a phone number or an email so we can reach you. We never share your details.

You may also like

Free

Includes certificate

Enrol free