Data Type in C
Data Type in C
Topperworld.in
Data Type in C
Basic types
Here's a table containing commonly used types in C programming for quick
access.
char 1 %c
float 4 %f
double 8 %lf
©Topperworld
C Programming
signed char 1 %c
unsigned char 1 %c
©Topperworld
C Programming
All the other types of data types (derived and user-defined data types)
are derived from these data types. Primary data types in C are of 4
types: int, char, float, and double.
Here are the five primitive or primary data types that one can find in C
programming language:
Integer – We use these for storing various whole numbers, such as 5,
8, 67, 2390, etc.
Character – It refers to all ASCII character sets as well as the single
alphabets, such as ‘x’, ‘Y’, etc.
Double – These include all large types of numeric values that do not
come under either floating-point data type or integer data type.
Floating-point – These refer to all the real number values or decimal
points, such as 40.1, 820.673, 5.9, etc.
Various keywords are used in a program for specifying the data types
mentioned above. Here are the keywords that we use:
The size of every data type gets defined in bytes/ bits. Also, these data types
can hold a very wide range of values.
©Topperworld
C Programming
The data types originally present in a program may not offer a wide
variety of functions.
But despite the various basic as well as derived data types present in the
C language, there is a special feature using which we can define custom
data types of our own, on the basis of our needs.
Structures
Union
Typedef
enum
©Topperworld
C Programming
short
long
unsigned
Signed
©Topperworld
C Programming
Example
// C Program to print size of
// different data type in C
#include <stdio.h>
int main()
{
int size_of_int = sizeof(int);
int size_of_char = sizeof(char);
int size_of_float = sizeof(float);
int size_of_double = sizeof(double);
return 0;
}
Output:
The size of int data type : 4
The size of char data type : 1
The size of float data type : 4
The size of double data type : 8
©Topperworld