C Fundamentals

Beginner
17 min read
Updated: Nov 2026
1 example
11 guides

Definition and Usage

C fundamentals are the pieces every program is built from: a program structure with main, the syntax rules the compiler enforces, variables and data types that hold values, and input/output with printf and scanf. Master these first and every later topic (loops, pointers, structs) becomes easier to read.

Compile early, compile often.

Run gcc file.c -std=c11 -Wall -Wextra -o out after every small change. Warnings catch uninitialized variables and wrong format specifiers before they become bugs.

Learning Path

Work through the stages in order, or jump to a topic from the index below (11 tutorials).

C Examples

A quick taste of fundamentals. Compile with gcc file.c -std=c11 -Wall -o out.

Example 1 — A first program that uses most basics

Variables, a constant, printf, and a computed value in one short program.

C
#include <stdio.h>

#define TAX_RATE 0.10

int main(void) {
    int quantity = 3;
    double price = 49.50;
    double total = quantity * price * (1.0 + TAX_RATE);

    printf("Items: %d\n", quantity);
    printf("Total: %.2f\n", total);
    return 0;
}

How It Works

  1. #define creates a text constant that the preprocessor substitutes.
  2. quantity is an int; price and total are double values.
  3. %d prints an int and %.2f prints a double with two decimals.
  4. 3 * 49.50 * 1.10 = 163.35.

C Fundamentals Topics

Every guide in this section with a one-line summary (11 tutorials).

Program basics

4 tutorials

How a C file is laid out and the rules the compiler enforces.

TopicDescriptionTutorial
Program structureThe parts of a C program: includes, main, statements, and return.Try it
SyntaxThe grammar rules of C: tokens, semicolons, braces, case sensitivity, and whitespace.Try it
CommentsAdd notes to your code with // and /* */ comments.Try it
Keywords and identifiersReserved words versus the names you choose for variables and functions.Try it

Values and types

4 tutorials

Store data, fix it with constants, and understand how types behave.

TopicDescriptionTutorial
VariablesDeclare, initialize, and update named storage for values.Try it
ConstantsValues that must not change: literals, #define, const, and enum.Try it
Data typesint, char, float, double, and the size and range of each type.Try it
Type conversionImplicit promotion and explicit casts between types.Try it

Input and output

3 tutorials

Talk to the user with printf, scanf, format specifiers, and escapes.

TopicDescriptionTutorial
Input and outputPrint with printf and read input with scanf, getchar, and fgets.Try it
Format specifiersThe % codes that tell printf and scanf how to treat each value.Try it
Escape sequencesBackslash codes for newlines, tabs, quotes, and special characters.Try it

Edge Cases & Pitfalls

Common mistakes when learning fundamentals in C.

scanf

Wrong format specifier

Using %d for a double (or %f for an int) is undefined behavior. Match the specifier to the type.

init

Uninitialized variables

A local variable holds garbage until you assign it. Always give variables a value before reading them.

int/

Integer division

5 / 2 is 2, not 2.5. Make one operand a double when you need a fraction.

Key Takeaways

  • Structure: every program starts at main.
  • Types: choose the smallest type that clearly fits your data.
  • Output: match each format specifier to its argument type.

One line: C fundamentals are the pieces every program is built from: a program structure with main, the syntax rules the compiler enforces, variables and data types that hold values, and input/output with printf and scanf.

Frequently Asked Questions

Start with program structure and syntax, then variables, data types, and printf/scanf. After that, move to operators, control statements, and loops.
No. A text editor, a terminal, and GCC or Clang are enough. Any online C compiler also works for the short examples.
Examples compile with C11 (-std=c11). Features from C99 such as // comments and mixed declarations are noted where they appear.

Next: Program Structure

The parts of a C program: includes, main, statements, and return.

Continue →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful