C Data Types int, float, char, void, sizeof is an important C Language topic because it appears in real projects, debugging sessions, and interviews. Learn the meaning first, then connect it to a small working example so the rule does not stay abstract.
For this page, focus on what problem C Data Types int, float, char, void, sizeof solves, where developers usually make mistakes, and how to verify the result. The audit note for this lesson was: under 650 content words; limited checklist/practice/mistake/FAQ notes .
A strong understanding of C Data Types int, float, char, void, sizeof should include syntax, behavior, one realistic use case, one failure case, and one quick way to check your work with tools or output.
C Data Types int float char void sizeof should be studied as a practical C Language lesson, not as a label. Start by naming the input, the rule that changes the input, and the result a learner should be able to predict after reading the page.
In the c-language > data-types page, the notes should connect the definition with a working scenario, a mistake that beginners actually make, and the exact check that proves the fix. That makes the topic useful for coding, debugging, and interview revision.
C provides several built-in data types. The size of each type may vary by platform, but the values below are typical for a 64-bit system.
| Type | Size | Format Specifier | Range | Description |
|---|---|---|---|---|
| int | 4 bytes | %d or %i | -2,147,483,648 to 2,147,483,647 | Integer numbers |
| float | 4 bytes | %f | ~3.4 x 10^-38 to 3.4 x 10^38 | Single-precision decimal |
| double | 8 bytes | %lf | ~1.7 x 10^-308 to 1.7 x 10^308 | Double-precision decimal |
| char | 1 byte | %c | -128 to 127 (or 0 to 255) | Single character |
| void | - | - | - | No value (used for functions/pointers) |
Type modifiers change the size or sign of a base type. They can be combined with int, char, and double.
| Type | Size | Format Specifier | Range |
|---|---|---|---|
| short int | 2 bytes | %hd | -32,768 to 32,767 |
| unsigned int | 4 bytes | %u | 0 to 4,294,967,295 |
| long int | 4 or 8 bytes | %ld | -2,147,483,648 to 2,147,483,647 (min) |
| long long int | 8 bytes | %lld | -9.2 x 10^18 to 9.2 x 10^18 |
| unsigned long long | 8 bytes | %llu | 0 to 1.8 x 10^19 |
| unsigned char | 1 byte | %c | 0 to 255 |
| long double | 10 or 16 bytes | %Lf | Extended precision |
C also has derived data types that are built from primary types:
#include <stdio.h>
int main() {
int age = 25;
float price = 9.99f;
double pi = 3.14159265358979;
char grade = 'A';
printf("int: %d\n", age);
printf("float: %f\n", price);
printf("double: %lf\n", pi);
printf("char: %c\n", grade);
// Printing char as integer (ASCII value)
printf("char as int: %d\n", grade); // 65
return 0;
}
/*
Output:
int: 25
float: 9.990000
double: 3.141593
char: A
char as int: 65
*/
#include <stdio.h>
int main() {
// sizeof returns the size in bytes
printf("Size of char: %zu bytes\n", sizeof(char));
printf("Size of int: %zu bytes\n", sizeof(int));
printf("Size of float: %zu bytes\n", sizeof(float));
printf("Size of double: %zu bytes\n", sizeof(double));
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 int: %zu bytes\n", sizeof(unsigned int));
// Type modifiers in action
unsigned int population = 4294967295U; // max unsigned int
long long int bigNum = 9223372036854775807LL;
short int small = 32767;
printf("\nunsigned int: %u\n", population);
printf("long long int: %lld\n", bigNum);
printf("short int: %hd\n", small);
return 0;
}
/*
Output (64-bit system):
Size of char: 1 bytes
Size of int: 4 bytes
Size of float: 4 bytes
Size of double: 8 bytes
Size of long int: 8 bytes
Size of long long int: 8 bytes
Size of unsigned int: 4 bytes
*/
When studying C Data Types int, float, char, void, sizeof, separate three things: the concept, the syntax, and the situation where it is useful. This prevents the lesson from becoming a list of commands with no practical meaning.
In C Language, C Data Types int, float, char, void, sizeof becomes easier when you build a tiny example first, then increase complexity. Add one realistic input, one invalid or boundary input, and one explanation of why the result changes.
#include <stdio.h>
int main(void) {
printf("C Data Types int float char void sizeof: normal path\n");
return 0;
}
#include <stdio.h>
int main(void) {
int count = 0;
if (count == 0) printf("C Data Types int float char void sizeof: empty input\n");
return 0;
}
Memorizing C Data Types int float char void sizeof without the situation where it is useful.
Connect C Data Types int float char void sizeof to a concrete C Language task.
Testing C Data Types int float char void sizeof only with the perfect input.
Include empty, missing, duplicate, incompatible, or failed cases when relevant.
Changing code before reading the visible symptom or error message.
Inspect the output, state, configuration, or stack trace connected to C Data Types int float char void sizeof.
Memorizing C Data Types int float char void sizeof without the situation where it is useful.
Connect C Data Types int float char void sizeof to a concrete C Language task.
The common mistake is memorizing syntax without understanding when the behavior changes or fails.
Remember the problem it solves in C Language, then attach the syntax or steps to that problem.
You can predict the result of a small example, explain a failure case, and choose it over a nearby alternative for a clear reason.
They often copy the syntax but skip the state, input, dependency, selector, route, type, or configuration that controls the behavior.
Explore 500+ free tutorials across 20+ languages and frameworks.