![]() |
| Data Types in C Programming |
C Data Types: A Data type can store the value. Every variable in C has an initialize data type. It is specified the type of data that the variable can store like integer data type(int), character data type(char) , floating data type(float) and double data type etc.
C language is a statically type where every variable's data type must be specified at the declaration and once specified. It is a type of data which is used in the C program. A data types specifies the type of data stored in a variable.
There are two types of data type.
- Basic Data Types
- Derived
Basic Data Types in C
| Data Type | Description | Size (bytes) | Format Specifier |
|---|---|---|---|
| int | Integer can stores whole numbers without decimals. | 2 or 4 | %d or %i |
| float | float can stores only floating-point numbers. | 4 | %lf |
| char | char can stores only a single character value. | 1 | %c |
| double | double can stores double-precision floating-point numbers. | 8 | %lf |
| void | void Represents the absence of a value do not return a value. | 0 | N/A |
Derived Data Types in C
Array Data Type: Array is a collection of elements of the same data type stored contiguous memory location in a same single name.Pointer Data Type: Pointer is a special type variable. It can store only address of another variable. Pointer denoted by (*) symbols.
Function Data Type: Function is a name of block of code that perform an specific task and small number of block.
User Defined Data Types in C
Structure(struct): Structure is a group of multiple variable of different data types in a single name.Union(union): Union allows multiple variables to share the same memory location. But union can store only one value at a time.
Enumeration(enum): Enum is a symbolic name with integer constants.
Typedef: Typedef can be used alias or new name for existing data type name.
Type of Data Types in C
| Basic Data Type | Derived Data Type |
|---|---|
| Integer Type(int) | Pointer |
| Floating Type(float) | Array |
| Character Type(char) | Structure |
| N/A | Union |
Integer Data Types in C
| Data Type | Size in bytes | Range |
|---|---|---|
| short | 2 | -32768 to +32767 |
| int | 2 | -32768 to +32767 |
| unsigned int | 2 | 0 to 65536 |
| long | 4 | -2147483648 to +2147483647 |
| unsigned long int | 4 | 0 to 4,294,967,295 |
Example of Integer Data Types in C
|
#include<stdio.h> #include<conio.h> void main(){ clrscr(); int x=100; printf("Value of x:%d",x); getch(); } ============OUTPUT============ Value of x:100 |
Float Data Types in C
| Data Type | Size in bytes | Range |
|---|---|---|
| float | 4 | 3.4E-38 to 3.4E+38 |
| double | 8 | 1.7E-308 to 1.7E+308 |
| Long double | 10 | 3.4E-4932 to 1.1E+4932 |
Example of Float Data Types in C
|
#include<stdio.h> #include<conio.h> void main(){ clrscr(); float marks=76.8; printf("Value of Marks:%f",marks); getch(); } ============OUTPUT============ Value of Marks:76.8 |
Character Data Types in C
| Data Type | Size in bytes | Range |
|---|---|---|
| char | 1 | -128 to +127 |
| signed char | 1 | -128 to +127 |
| unsigned char | 1 | 0 to 255 |
Example of Character Data Types in C
|
#include<stdio.h> #include<conio.h> void main(){ clrscr(); char grade='J'; printf("Value of Grade:%c",grade); getch(); } ============OUTPUT============ Value of Grade:J |
Example Size Find Data Types in C
|
#include<stdio.h> #include<conio.h> void main(){ clrscr(); int x=100; float y=78.5; char c='J'; printf("Size of Integer Data:%d\n",sizeof(int)); printf("Size of Float Data:%d\n",sizeof(float)); printf("Size of Character Data:%d\n",sizeof(char)); printf("Size of Double Data:%d\n",sizeof(double)); getch(); } ============OUTPUT============ Size of Integer Data:4 Size of Float Data:4 Size of Character Data:1 Size of Double Data:8 |
Conclusion of Data Types in C
Conclusion: Data Types is a most important part of c programming language. It is a overview all data types. I can explain briefly define in the next topic simple and easy language. so you can support my content and suggestion any doubt you can email and comments.

0 Comments