C

C Tutorial — Learn C Programming

Key takeaway: This free C tutorial teaches you systems programming from scratch — variables, pointers, arrays, functions, structs, and memory management — with practical code examples you can compile and run.

C is a general-purpose, procedural programming language created in 1972. It is used for operating systems, embedded systems, game engines, and performance-critical applications. This tutorial is for beginners, CS students, and developers who want to understand how computers work at a low level.

Last updated: September 2026

Data Types in C

Data types specify the type of data that a variable can store. C provides several built-in data types to handle different kinds of data.

Basic Data Types

Data TypeSize (bytes)RangeFormat Specifier
char1-128 to 127%c
int4-2,147,483,648 to 2,147,483,647%d
float43.4E-38 to 3.4E+38%f
double81.7E-308 to 1.7E+308%lf

Modified Data Types

You can modify basic data types using type modifiers:

signed & unsigned

Controls whether the variable can hold negative values

short & long

Controls the size of the variable

Data Types Example
#include <stdio.h>

int main() {
    // Basic data types
    char letter = 'A';
    int age = 25;
    float height = 5.9;
    double pi = 3.141592653589793;
    
    // Modified data types
    unsigned int positive_number = 4000000000U;
    long long big_number = 9223372036854775807LL;
    short small_number = 32767;
    
    // Print values
    printf("Character: %c\n", letter);
    printf("Integer: %d\n", age);
    printf("Float: %.2f\n", height);
    printf("Double: %.15lf\n", pi);
    printf("Unsigned int: %u\n", positive_number);
    printf("Long long: %lld\n", big_number);
    printf("Short: %hd\n", small_number);
    
    // Size of data types
    printf("\nSize of data types:\n");
    printf("char: %zu bytes\n", sizeof(char));
    printf("int: %zu bytes\n", sizeof(int));
    printf("float: %zu bytes\n", sizeof(float));
    printf("double: %zu bytes\n", sizeof(double));
    
    return 0;
}
Important Note

The size of data types may vary depending on the system architecture. Use sizeof() operator to get the exact size on your system.

Explanation

  • Basic types:char, int, float, double represent common kinds of data with different sizes and ranges.
  • Modifiers:signed/unsigned, short/long adjust range and storage, impacting memory and overflow behavior.
  • Why it matters: Correct types prevent overflow, precision loss, and undefined behavior when performing operations.
  • Portable code: Use sizeof and format specifiers (%d, %u, %f, %lf) to print values reliably across systems.
Keywords
C data types, signed vs unsigned, short long, sizeof, format specifiers
Quick Tips
  • Match printf/scanf format specifiers with the variable type to avoid undefined behavior.
  • Prefer unsigned for values that cannot be negative (e.g., counts, sizes).
  • Be cautious with integer division; cast to double for precise results when needed.

Frequently Asked Questions

C is a foundational systems programming language that's been around since the 1970s. It's the base for Linux, Windows, and most operating systems. Learning C gives you deep understanding of memory, pointers, and how computers work — skills that transfer to every other language. According to the TIOBE Index, C consistently ranks in the top 2 most popular languages.

No, zero experience needed. Our C programming tutorial is designed for complete beginners. We start with Hello World and gradually progress to pointers and memory management. Basic computer literacy and logical thinking are helpful but not required.

Just a C compiler — or use our free online compiler. For beginners, our online C compiler requires no installation. For local development, use GCC (available on all platforms). IDEs like VS Code, Code::Blocks, or Dev-C++ also work well.

2–4 weeks for basics, 3–6 months for proficiency. With 1–2 hours daily practice, you can learn syntax, loops, and functions in a few weeks. Mastering pointers, memory management, and data structures takes 6–12 months. Practice with our C programming examples.

C programming skills open doors to various career paths including system programming, embedded systems development, operating system development, device driver programming, game development, and firmware development. Many companies in automotive, aerospace, telecommunications, and IoT sectors actively seek C programmers.

Yes, extremely relevant. C consistently ranks in the top 2 on TIOBE and powers Linux, embedded systems, IoT, automotive software, and game engines. Understanding C makes you a better programmer in any language since most runtimes (Python, Java, Node.js) are themselves written in C.