FREE COURSE | BEGINNER
C Programming Fundamentals
Learn procedural programming, compiled code and problem-solving through practical C17 examples.
Learning objectives
Compile C programs, use variables and control structures, work with arrays and functions, explain basic pointers, and build a simple grade calculator.
Prerequisites: basic computer and terminal skills. GCC compiler · C language reference.
01. Introduction to C Programming
C is a general-purpose, compiled language. Source code is translated into an executable by a compiler. It is widely used in systems and embedded programming. The main function is the entry point of a hosted C program.
C source code
Expected output (original example)
Hello, C!
Editing the code does not change this reference output. Compile locally to test your changes.
Try it yourself
Change the greeting.
02. Installation and Program Structure
Install a C compiler such as GCC. Save a program as hello.c, compile with gcc -std=c17 -Wall -Wextra hello.c -o hello, then run ./hello (or hello.exe on Windows). The stdio.h header declares standard input/output functions. Statements end with semicolons.
C source code
Expected output (original example)
Welcome to LOOPNODELAB
Editing the code does not change this reference output. Compile locally to test your changes.
Try it yourself
Compile the example and change the message.
03. Variables, Data Types and Input/Output
Use int for integers, double for floating-point values and char for characters. printf formats output; scanf reads input. Always check scanf’s return value before using input. The example expects an integer.
C source code
Expected output (original example)
Age: 20
Sample input: 20
Editing the code does not change this reference output. Compile locally to test your changes.
Try it yourself
Try input 20, then try invalid text.
04. Operators and Expressions
Arithmetic operators include +, -, *, / and %. Integer division truncates toward zero. Use a floating-point operand for fractional division. Comparison operators return 0 or 1.
C source code
Expected output (original example)
Integer: 3 Decimal: 3.50
Editing the code does not change this reference output. Compile locally to test your changes.
Try it yourself
Predict the remainder using a % b.
05. Conditional Statements
if, else if and else select a branch based on a condition. Use == for equality and = for assignment. Logical operators && and || combine conditions.
C source code
Expected output (original example)
Passed
Editing the code does not change this reference output. Compile locally to test your changes.
Try it yourself
Change the score to 74 and 75.
06. Loops and Iteration
A for loop is useful when the iteration count is known. while checks its condition before each iteration; do-while checks afterward. Ensure the condition eventually becomes false.
C source code
Expected output (original example)
1 2 3 4 5
Editing the code does not change this reference output. Compile locally to test your changes.
Try it yourself
Change the loop to print even numbers from 2 to 10.
07. Arrays, Functions and Pointer Basics
Arrays store elements of the same type, indexed from zero. Functions group reusable logic. A pointer stores an address; & obtains an address and * dereferences a valid pointer. Never access outside an array or dereference an invalid pointer.
C source code
Expected output (original example)
First: 80 Total: 255
Editing the code does not change this reference output. Compile locally to test your changes.
Try it yourself
Add another score and update the array length.
08. Interactive Practice Lab
Trace a loop by changing its upper limit in the simulator below. The displayed C program can be copied into a local compiler. The browser simulation does not compile arbitrary C code.
C source code
Expected output (original example)
Sum: 15
Editing the code does not change this reference output. Compile locally to test your changes.
Loop simulator
Sum: 15
JavaScript simulation of the loop, not a C compiler.
Try it yourself
Predict the sum for 10 before running the simulation.
09. Mini Project: Student Grade Calculator
Combine arrays, loops, arithmetic and decisions to calculate an average from three fictional scores. This is a practice grading rule, not an institutional policy.
C source code
Expected output (original example)
Average: 85.00 Passed
Editing the code does not change this reference output. Compile locally to test your changes.
Try it yourself
Modify the scores, then extend the program to validate user input between 0 and 100.