![]() We use the void keyword for void data type. The void data type is used when a function does not return anything. This data type is mostly used when we define functions. We can perform addition, subtraction, division and multiplication operations on double data type. double a = 10.09 ĭouble has more precision than flaot so double gives more accurate results as compared to float. It occupies 8 bytes of memory and ranges from 1e-37 to 1e+37. ĭouble: We use the keyword double for double data type.We can perform addition, subtraction, division, and multiplication operations on float data type. For example, float a = 0.05 įloat c = 1 // it will become c = 1.000000 because of type-casting It occupies 4 bytes of memory and ranges from 1e-37 to 1e+37. įloating-point: We use the keyword float for floating-point data type.We can perform addition, subtraction, division, multiplication, bitwise and modulo operations on int data type. The range of int is -2,147,483,648 to 2,147,483,647 and it occupies 2 or 4 bytes of memory, depending on the system you’re using. The int data type is used to store non-fractional numbers which includes positive, negative and zero values. Integer: We use the keyword int for integer data type. ![]() We can perform addition and subtraction operations on char but the ASCII value should not exceed 127. For example, char a = 'a' įor char datatype, it is necessary to enclose our data in single quotes. Some conversions are lossless, but others. For example, INTEGER data can be converted to FLOAT. ![]() We can store alphabets from A-Z(and a-z) and 0-9 digits using char. In some cases, data of one type can be converted to another type. It is used to store single bit characters and occupies 1 byte of memory. The C language has 5 basic (primary or primitive) data types, they are:Ĭharacter: We use the keyword char for character data type. Enumeration enums Bool type true or false void Empty value Data Types in Cīroadly, there are 5 different categories of data types in the C language, they are: Type Example Basic character, integer, floating-point, double. For code examples, checkout Using C Datatypes tutorial. In this tutorial, we have explained the different data types used in C language. Whenever we define a variable or use any data in the C language program, we have to specify the type of the data, so that the compiler knows what type of data to expect.įor example, you may want to use a number like 1, 2, 100, or a decimal point number like 99.95, 10.5, or a text, like "Studytonight", all these values are handled differently by the C language compiler, hence, we use data types to define the type of data used in any program.Įach data type occupies some memory, has a range of values and a set of operations it allows to be performed on itself. As the name suggests, a Datatype defines the type of data being used. ![]()
0 Comments
Leave a Reply. |