Today, we will learn about Data Types in C Language. As in earlier posts I have introduced you with C Language. C language is the worlds most used and very powerful language for making Windows Application also Unix and Linux applications.
Basic Data Types in C Language
We have basically five basic data types in C Language. These are as following:
Character: char
Char
is used to store single characters. It typically occupies 1 byte of memory.
You can see the declaration and definition of the char type variable using following example.
//Declaration
char ch;
char ch1, ch2;
//Declaration with Definition
char ch1 = 'A';
Integer: int
Int
is used to store integers (whole numbers). The size of int
depends on the compiler and the architecture, but it’s usually 4 bytes.
You can see the declaration and definition of the int
type variable using following example.
//Declaration
int a;
int b, c;
//Declaration with Definition
int a = 5;
b = 7;
Float: float
float
is used to store floating-point numbers (decimal numbers). It normally occupies 4 bytes.
You can see the declaration and definition of the float
type variable using following example.
//Declaration Only
float weight, height;
//Declaration and Definition
float weight1 = 68.5;
height = 1.5;
Double: double
double
is used to store double-precision floating-point numbers. It occupies 8 bytes. The double data type ranges from 1.7E-308 to 1.7E+308.
You can see the declaration and definition of the double
type variable using following example.
//Declaration
double d1, d2;
//Definition
d1 = 1.9876;
Void: void
void indicates the absence of data type. It’s commonly used as a return type for functions that do not return a value. most common being the main
itself in many programs.
void Welcome()
{
printf("Welcome to DotNet Guide!!\n");
}
We can further divide some of these data types into signed and unsigned data type and there are derived data types like pointer
, array
, structure
, union
and enumeration
. For technical content in Audio Video format, please subscribe to our YouTube channel.