
Rules regarding size qualifier as per ANSI C standard Example to use size qualifier Data typeĭefines a min 12 bytes double precision floating point number In addition, double type supports long qualifier. Size qualifier is generally used with integer type. C supports two size qualifier, short and long. Size qualifier in C is used to alter size of a primitive data type. Note: Parts in the square brackets are optional and parts in angle bracket are mandatory. They are used along with the basic data types in any of the two given syntax. There are two types of data type qualifiers in C, size and sign qualifier. They are used to alter the behaviour and property of basic data types yielding new type with new property and behaviour. Qualifiers are optional add-on to the basic data types. Derived types are created using basic data types with modified behaviour and property. Derived data typesĪ derived data type is defined using combination of qualifiers along with the primitive data type. We will learn about void types in later section of this programming tutorial series.
#Basic data types in c programming language code
In the above code ptr is defined as a void pointer. void keyword is used to define a function return type or a generic pointer.Įxample to define void pointer type – void * ptr void typeĪs name suggests void internally does not store anything. Add suffix f or F after floating point literal to specify type as float.

Precision of float type is of 6 decimal places and double is of 15 decimal places.Įxample to define float type variable – float percentage = 95.67 Ĭ considers floating point literal as double type. Number of significant digits after decimal point is known as its precision. Whereas double defines a double precision floating point number that can store 2.3E-308 to 1.7E+308. float defines a single precision floating point number that can store 1.2E-38 to 3.4E+38. Float type floatĪ real type value in C is defined with float or double keyword. In above code roll is defined as an integer type variable and can store any number in int range. Size of int is 2 or 4 bytes (compiler dependent) and can store values up to -32,768 to 32,767 or -2,147,483,648 to +2,147,483,647.Įxample to define int type variable – int roll = 24 In C programming int keyword is used to define a number type.
#Basic data types in c programming language how to
Read more – How to declare character literal (value)? Integer type int In above code grade is defined as a character type variable and can store any character. Size of char type is 1 byte and can store 128 characters.Įxample to define char type variable – char grade = 'A' Character type charĪny single character value in C is represented using char. For example, size of int type varies from compiler to compiler, but it must be at least 2 bytes on every compiler. C standard requires only the minimum size to be fulfilled by every compiler for each data type.

The size and range of a data type is machine dependent and may vary from compiler to compiler.
