Less Used Format Specifiers in C

Some format specifiers are not used in every beginner program, but they are important for exams, number systems, memory concepts and larger integer values.

First study the common page: Format Specifiers in C.

Less Used Format Specifiers Table

Format Specifier Used For Data Type / Use Example
%u Unsigned integer unsigned int unsigned int x = 50;
%ld Long integer long int long int n = 100000;
%lld Long long integer long long int long long int n = 9000000000;
%hd Short integer short int short int x = 10;
%x Hexadecimal in lowercase int 255 prints ff
%X Hexadecimal in uppercase int 255 prints FF
%o Octal number int 8 prints 10
%e or %E Scientific notation float, double 1234.5 prints like 1.234500e+003
%p Address or pointer value Pointer printf("%p", &x);
%zu Result of sizeof size_t printf("%zu", sizeof(int));

1. %u - Unsigned Integer

%u is used for unsigned int. Unsigned integers store only zero and positive values.

#include <stdio.h>

int main() {
    unsigned int count = 50;
    printf("Count = %u", count);
    return 0;
}

Output:

Count = 50

Explanation:

  • count is an unsigned integer.
  • %u prints unsigned integer values.

2. %ld, %lld and %hd - Size Based Integer Specifiers

These specifiers are used when integer values are stored using short, long or long long.

#include <stdio.h>

int main() {
    short int small = 10;
    long int population = 1000000;
    long long int distance = 9000000000;

    printf("Small = %hd\n", small);
    printf("Population = %ld\n", population);
    printf("Distance = %lld", distance);
    return 0;
}

Output:

Small = 10

Population = 1000000

Distance = 9000000000

Explanation:

  • %hd prints short integer.
  • %ld prints long integer.
  • %lld prints long long integer.

3. %x, %X and %o - Number System Specifiers

These specifiers print integer values in hexadecimal and octal number systems.

#include <stdio.h>

int main() {
    int number = 255;

    printf("Hex lowercase = %x\n", number);
    printf("Hex uppercase = %X\n", number);
    printf("Octal = %o", number);
    return 0;
}

Output:

Hex lowercase = ff

Hex uppercase = FF

Octal = 377

Explanation:

  • %x prints hexadecimal value in lowercase.
  • %X prints hexadecimal value in uppercase.
  • %o prints octal value.

4. %e and %E - Scientific Notation

%e and %E print decimal values in scientific notation. This is useful for very large or very small numbers.

#include <stdio.h>

int main() {
    double value = 12345.678;

    printf("Scientific = %e\n", value);
    printf("Scientific = %E", value);
    return 0;
}

Output:

Scientific = 1.234568e+004

Scientific = 1.234568E+004

Explanation:

  • %e prints scientific notation with lowercase e.
  • %E prints scientific notation with uppercase E.

6. %zu - sizeof Result Specifier

%zu is used to print values of type size_t. The sizeof operator returns a size_t value.

#include <stdio.h>

int main() {
    printf("Size of int = %zu bytes", sizeof(int));
    return 0;
}

Possible Output:

Size of int = 4 bytes

Explanation:

  • sizeof(int) returns the memory size of int in bytes.
  • %zu is the correct specifier for printing sizeof result.

6. %zu - sizeof Result Specifier

%zu is used to print values of type size_t. The sizeof operator returns a size_t value.

#include <stdio.h>

int main() {
    printf("Size of int = %zu bytes", sizeof(int));
    return 0;
}

Possible Output:

Size of int = 4 bytes

Explanation:

  • sizeof(int) returns the memory size of int in bytes.
  • %zu is the correct specifier for printing sizeof result.

Combined Example of Less Used Format Specifiers

#include <stdio.h>

int main() {
    unsigned int rank = 5;
    long int population = 1000000;
    int number = 255;

    printf("Rank = %u\n", rank);
    printf("Population = %ld\n", population);
    printf("Hex = %X\n", number);
    printf("Octal = %o\n", number);
    printf("Size of int = %zu bytes", sizeof(int));

    return 0;
}

Possible Output:

Rank = 5

Population = 1000000

Hex = FF

Octal = 377

Size of int = 4 bytes

Explanation:

  • %u prints unsigned integer.
  • %ld prints long integer.
  • %X prints hexadecimal in uppercase.
  • %o prints octal value.
  • %zu prints sizeof result.

Summary:

  • Less used format specifiers are important for special cases.
  • %u is used for unsigned integer.
  • %ld, %lld and %hd are used for different integer sizes.
  • %x, %X and %o are used for number systems.
  • %p is used for addresses and %zu is used for sizeof result.

Welcome to ShikshaSanchar!

ShikshaSanchar is a simple and helpful learning platform made for students who feel stressed by exams, assignments, or confusing topics. Here, you can study with clarity and confidence.

Here, learning is made simple. Notes are written in easy English, filled with clear theory, code examples, outputs, and real-life explanations — designed especially for students like you who want to understand, not just memorize.

Whether you’re from school, college, or someone learning out of curiosity — this site is for you. We’re here to help you in your exams, daily studies, and even to build a strong base for your future.

Each note on this platform is carefully prepared to suit all levels — beginner to advanced. You’ll find topics explained step by step, just like a good teacher would do in class. And the best part? You can study at your pace, anytime, anywhere.

Happy Learning! – Team ShikshaSanchar