Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH RUST

C Tutorial

C HOME C Intro C Get Started C Syntax C Output C Comments C Variables C Data Types C Constants C Operators C Booleans C If...Else C Switch C While Loop C For Loop C Break/Continue C Arrays C Strings C User Input C Memory Address C Pointers

C Functions

C Functions C Function Parameters C Scope C Function Declaration C Recursion C Math Functions

C Files

C Create Files C Write To Files C Read Files

C Structures

C Structures C Nested Structures C Structs & Pointers C Unions C typedef

C Enums

C Enums

C Memory

C Memory Management

C Errors

C Errors C Debugging C NULL C Error Handling C Input Validation

C More

C Date C Random Numbers C Macros C Organize Code C Storage Classes C Bitwise Operators C Fixed Width Integers

C Projects

C Projects

C Reference

C Reference C Keywords C <stdio.h> C <stdlib.h> C <string.h> C <math.h> C <ctype.h> C <time.h>

C Examples

C Examples C Real-Life Examples C Exercises C Quiz C Compiler C Syllabus C Study Plan C Certificate

C Extended Types


More Data Types

Besides the basic types (int, float, double, char), C also gives you extended keywords (short, long, unsigned) to control how large the number is, or whether it can be negative:

Type Size* Range (commonly) Format Specifier
short int 2 bytes -32,768 to 32,767 %hd
unsigned int 2 or 4 bytes 0 to 65,535 (2 bytes)
0 to 4,294,967,295 (4 bytes)
%u
long int 4 or 8 bytes -2,147,483,648 to 2,147,483,647 (4 bytes)
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (8 bytes)
%ld
long long int 8 bytes -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 %lld
unsigned long int 4 or 8 bytes 0 to 4,294,967,295 (4 bytes)
0 to 18,446,744,073,709,551,615 (8 bytes)
%lu
unsigned long long int 8 bytes 0 to 18,446,744,073,709,551,615 %llu
long double 8, 12, or 16 bytes Implementation-dependent, but more precision than double %Lf

unsigned means the type can only store non-negative values (0 and up).

Note: The size of these types can differ between systems (for example, 2 or 4 bytes, or 4 or 8 bytes), depending on whether the computer is older or newer, 32-bit or 64-bit, and which compiler is used.

Here is an example of how you can create and print these extended types:

Example

int normalInt = 1000;                       // standard int 
double normalDouble = 3.14;                 // standard double

short int small = -100;                     // smaller int
unsigned int count = 25;                    // only positive int
long int big = 1234567890;                  // larger int
long long int veryBig = 9223372036854775807; // very large int
unsigned long long int huge = 18446744073709551615U; // very large, only positive
long double precise = 3.141592653589793238L; // extended precision

printf("Normal int: %d\n", normalInt);
printf("Normal double: %lf\n", normalDouble);
printf("Small: %hd\n", small);
printf("Count: %u\n", count);
printf("Big: %ld\n", big);
printf("Very Big: %lld\n", veryBig);
printf("Huge: %llu\n", huge);
printf("Precise: %Lf\n", precise);

Try it Yourself »

Note: These extended types are mostly used when you need very specific control over memory usage or number ranges.

Note: For everyday programming, int, float, double, and char are usually enough.


Check Size

*The exact sizes depend on your system and compiler. Remember that you can check them with the sizeof operator:

Example

printf("Size of int: %zu bytes\n", sizeof(int));
printf("Size of double: %zu bytes\n", sizeof(double));
printf("Size of short int: %zu bytes\n", sizeof(short int));
printf("Size of unsigned int: %zu bytes\n", sizeof(unsigned int));
printf("Size of long int: %zu bytes\n", sizeof(long int));
printf("Size of long long int: %zu bytes\n", sizeof(long long int));
printf("Size of unsigned long long int: %zu bytes\n", sizeof(unsigned long long int));
printf("Size of long double: %zu bytes\n", sizeof(long double));

Try it Yourself »

Tip: When you really need exact control over the size of your numbers, you can use the fixed-width types, which you will learn about later.

This page is just to show you that C has other extended types, but for now we will keep focusing on the basic types (int, float, double, char) in this tutorial.



×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.