• Home
  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • TypeScript
    • Introduction to TypeScript
    • TypeScript Developer
  • React.js
    • Introduction to React
    • React Developer
  • Python
    • Introduction to Python
    • Python Developer
  • C++
    • Introduction to C++
    • C++ Developer
  • C Language
    • Introduction to C
    • C Developer
  • Rust
    • Introduction to Rust
    • Rust Developer
  • Zig
    • Introduction to Zig
    • Zig Developer
  • Linux Shell
    • Introduction to the Linux Shell
    • Linux Shell Developer
  • Interactive Training
  • Pricing
  • Brainstorm
STEMTrainingGrounds
  • Courses
    • Home
    • JavaScript
      • Introduction to JavaScript
      • JavaScript Developer
    • TypeScript
      • Introduction to TypeScript
      • TypeScript Developer
    • React
      • Introduction to React
      • React Developer
    • Python
      • Introduction to Python
      • Python Developer
    • C++
      • Introduction to C++
      • C++ Developer
    • C Language
      • Introduction to C
      • C Developer
    • Rust
      • Introduction to Rust
      • Rust Developer
    • Zig
      • Introduction to Zig
      • Zig Developer
    • Linux Shell
      • Introduction to the Linux Shell
      • Linux Shell Developer
  • Interactive Training
  • Pricing
  • Reading Grounds

Quick Links

  • About Us
  • Pricing
  • Partnership
  • Brainstorm
  • Terms
  • Privacy
  • Refunds
  • Featured on DanielLaunches

Courses

  • JavaScript
    • Introduction to JavaScript
    • JavaScript Developer
  • TypeScript
    • Introduction to TypeScript
    • TypeScript Developer
  • React
    • Introduction to React
    • React Developer
  • Python
    • Introduction to Python
    • Python Developer
  • C++
    • Introduction to C++
    • C++ Developer
  • C Language
    • Introduction to C
    • C Developer
  • Rust
    • Introduction to Rust
    • Rust Developer
  • Zig
    • Introduction to Zig
    • Zig Developer
  • Linux Shell
    • Introduction to the Linux Shell
    • Linux Shell Developer

Newsletter

Subscribe to our free monthly newsletter, for a quick update on Python, JavaScript, and React news

© 2025 - 2026 STEMTrainingGrounds. All Rights Reserved.

C Developer - Lesson 3

Lesson not found

Integer Types

Lesson Progress: 0%

Lesson Progress: 0%
Integer Types
Lesson Incomplete
Lesson not found

Integer types store whole numbers — numbers without a decimal point. C provides several integer types that use different amounts of memory and can hold different ranges of values. The most common is int, but there is also short for smaller values, long for larger values, and unsigned int for non-negative numbers. Choosing the right integer type helps your program use memory efficiently and avoid errors when values go out of range. Understanding integer types is a key step toward writing professional C code that runs well on any system.

Code Example
#include <stdio.h>

int main() {
    int a = 100;
    printf("%d\n", a);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • int is the standard integer type and can hold whole numbers like 100, -5, or 0.
  • Most C programs use int as the default choice for counting, indexing, and simple math.
  • On most modern systems, int uses 4 bytes of memory and can store values from about -2 billion to +2 billion.
  • The %d format specifier prints an int value.
  • Declaring int a = 100; creates a variable named a holding the value 100.
Code Example
#include <stdio.h>

int main() {
    short b = 25;
    printf("%d\n", b);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • short is a smaller integer type that uses less memory than int.
  • A short typically uses 2 bytes and holds values from about -32,000 to +32,000.
  • Use short when you know your numbers will stay small and you want to save memory.
  • Even though the variable is short, you can still print it with %d because short values are automatically promoted to int when passed to printf.
  • The declaration short b = 25; works just like int, but the variable can only hold a smaller range of numbers.
Code Example
#include <stdio.h>

int main() {
    long c = 50000;
    printf("%ld\n", c);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • long is a larger integer type that can hold bigger values than int.
  • On many systems, long uses 8 bytes and can store values up to about 9 quintillion.
  • The format specifier for long is %ld (long decimal).
  • Use long when you need to work with very large whole numbers that would not fit in an ordinary int.
  • Writing long c = 50000; creates a long variable, even though 50000 would also fit in an int.
Code Example
#include <stdio.h>

int main() {
    unsigned int d = 300;
    printf("%u\n", d);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • unsigned int can only hold non-negative numbers (zero or positive).
  • Because it does not need to store negative values, an unsigned int can hold twice as many positive numbers as a regular int.
  • The format specifier for unsigned int is %u (unsigned decimal).
  • Use unsigned for values that should never be negative, like counts, ages, or sizes.
  • The line unsigned int d = 300; declares an unsigned variable and stores 300 in it.
Code Example
#include <stdio.h>

int main() {
    int x = 7;
    int y = 2;
    printf("%d\n", x / y);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • When you divide two integers in C, the result is truncated — the decimal part is dropped.
  • 7 / 2 equals 3 in integer math, not 3.5, because both values are int.
  • This behavior is called integer division and is an important detail to remember when working with whole numbers.
  • Even if you store the result in a double, the division happens first using integer rules.
  • If you need a fractional result, at least one of the values must be a floating-point type like double or float.
Code Example
#include <stdio.h>

int main() {
    int z = -15;
    printf("%d\n", z);
    return 0;
}

Instructions

▼ ← Click the triangle to hide or reveal instructions.

C Code Editor

Task Incomplete

Editor Input:

Editor Output:

Click "Run Code" to see the output here
  • Integer types can store negative values as well as positive ones.
  • int z = -15; stores the negative number -15 in the variable z.
  • The %d format specifier handles negative numbers automatically and prints the minus sign.
  • signed is the default for int, short, and long, meaning they can hold both positive and negative values.
  • Only unsigned types forbid negative values, which doubles the positive range.

Test Incomplete

What is the standard integer type in C?

Question #

1/15

Score

0/0 - 0.0 %