modifiers in C.
Hello coders! Welcome back!
Today we are looking into different modifiers used in C language.
The modifiers used in C are short, long, signed, unsigned.
Short and long makes the data type to consume less or memory space respectively.
Whereas signed and unsigned makes the data type contain positive or negative numbers.
💡NOTE:- By default, int of some variable name is always a signed integer. Means by default it contains both negative and positive numbers.
unsigned int of some variable name allows only positive numbers.
sizeof is the operator or keyword used to find the size of the datatype. It is a unary operator.
Will look into some programs to get a clear idea-
<limit.h> is the header file to find the maximum and minimum range of a variable of a particular data type.
SHRT_MIN & SHRT_MAX are the symbolic constants of limit.h header file.
Similarly, you can find the range of the desired datatype with modifiers.
USHRT_MAX is the symbolic constant for a short unsigned integer.
%u is used as a format specifier for an unsigned integer.
We don't have USHRT_MIN (unsigned minimum range) as a symbolic constant. Because we know that unsigned numbers include only positive numbers and hence the minimum number is 0.
Here is a list of format specifiers indicating respective data types with modifiers.
%d → signed integer.
%u → unsigned integer.
%ld → signed long integer.
%lu → unsigned long integer.
%lld→ long long integer.
%llu→ unsigned long long integer.
Maximum bytes a long integer can hold is 8 bytes.
I hope so you got a clear idea about modifiers. If any quires drop a comment.
Happy learning!
Today we are looking into different modifiers used in C language.
The modifiers used in C are short, long, signed, unsigned.
Short and long makes the data type to consume less or memory space respectively.
Whereas signed and unsigned makes the data type contain positive or negative numbers.
💡NOTE:- By default, int of some variable name is always a signed integer. Means by default it contains both negative and positive numbers.
unsigned int of some variable name allows only positive numbers.
sizeof is the operator or keyword used to find the size of the datatype. It is a unary operator.
Will look into some programs to get a clear idea-
<limit.h> is the header file to find the maximum and minimum range of a variable of a particular data type.
SHRT_MIN & SHRT_MAX are the symbolic constants of limit.h header file.
Similarly, you can find the range of the desired datatype with modifiers.
USHRT_MAX is the symbolic constant for a short unsigned integer.
%u is used as a format specifier for an unsigned integer.
We don't have USHRT_MIN (unsigned minimum range) as a symbolic constant. Because we know that unsigned numbers include only positive numbers and hence the minimum number is 0.
Here is a list of format specifiers indicating respective data types with modifiers.
%d → signed integer.
%u → unsigned integer.
%ld → signed long integer.
%lu → unsigned long integer.
%lld→ long long integer.
%llu→ unsigned long long integer.
Maximum bytes a long integer can hold is 8 bytes.
I hope so you got a clear idea about modifiers. If any quires drop a comment.
Happy learning!
Comments
Post a Comment