Data Types In C-ProgrammingData types in C-Programming refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted. Data Types in c-Programming are used to:
In c programming language, data types are classified as follows…
Primary DatatypesThe primary data types in C-programming language are the basic datatypes. All the primary datatypes are already defined in the system. Primary datatypes are also called as Built-In datatypes. The following are the primary datatypes in c programming language.
Integer TypesInteger datatype is a set of whole numbers. Every integer value does not have the decimal value. We use the keyword “int” to represent integer datatype in c. We use the keyword int to declare the variables and to specify return type of a function. The integer datatype is used with different type modifiers like short, long, signed and unsigned. The following table provides complete details about integer datatype.
To get the exact size of a type or a variable on a particular platform, you can use the sizeof operator. The expressions sizeof(type) yields the storage size of the object or type in bytes. Given below is an example to get the size of int type on any machine − #include <stdio.h> #include <conio.h> int main() { clrscr(); printf("The Storage size for int : %d \n", sizeof(int)); getch(); } When you compile and execute the above program, it produces the following result on Linux − The Storage size for int : 4 1.3. FLOATING POINT DATA TYPE:Floating point data type consists of 2 types to understand it see the table given below.
Float data has two types;
1. FLOAT Data types in c
2. DOUBLE:
Example: #include <stdio.h> #include <Conio.h> int main() { clrscr(); printf(" The Storage size for float : %d \n", sizeof(float)); printf("The Minimum float positive value: %E\n", FLT_MIN ); printf(" The Maximum float positive value: %E\n", FLT_MAX ); printf(" The Precision value: %d\n", FLT_DIG ); getch(); } When you compile and execute the above program, it produces the following result on Linux − The Storage size for float : 4 The Minimum float positive value: 1.175494E-38 The Maximum float positive value: 3.402823E+38 The Precision value: 6 Character Datatype
Examplechar test = 'h'; Here, test is a character variable. The value of test is ‘h’. The void data type
Enumerated Data typeAn enumerated data types in c is a user-defined data type that consists of integer constants and each integer constant is given a name. The keyword “enum” is used to define enumerated datatype. Derived Data typesDerived data types in c are user-defined data types. The derived datatypes are also called as user defined datatypes or secondary datatypes. In c programming language, the derived datatypes are created using the following concepts…
|