The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
Data Type is nothing more than what type the data belongs to. In other words Data types are the storage format to store a data.
Data types are widely used in 90's programming languages like C, java and much more. Data types tells the compiler how to treat the data while performing any mathematical operation in it. Modern Compliers and Interpreters are capable of finding the types of data automatically so that users are provided with no-headache of mentioning data types. Languages like python, javascript, php etc are datatype free programming language.
C programming have minimal set of basic data types. Complex data types can be built using these basic data types. Data types are also known as primitive types. In C programming, the memory size of data types may change according to 32 (4 bytes) or 64 (8 bytes) bit operating system.
In C, 5 basic data types to define data.
The following table will demonstrate Data type's size and Data type's range for clarity view.
Data Type | Size (bits) | Range |
---|---|---|
void | 1 byte or 8 bits | nothing |
char | 1 byte or 8 bits | -128 to 127 |
int | 2 byte or 16 bits || 4 byte or 32 bits | -32768 to 32767 or -2,147,483,648 to 2,147,483,647 |
float | 4 bytes or 32bits || 8 byte or 64 bits | 3.4e-38 to 3.4e+38 |
double | 8 byte or 64 bits | 1.7e-308 to 1.7e+308 |
There are 2 types of conceptual data types in C programming
Derived data type | Enumeration Data Type |
---|---|
array, pointer, structure, union | enum |
Format Spectifiers in Programming language tells us which type of data to store and which type of data to print or to output.
Data Type | Keyword | Format Specifier |
---|---|---|
character | char | %c |
signed integer | int | %d or %i of %l |
unsigned integer | unsigned int | %u or %lu |
long double | long double | %ld |
string | char | %s |
floating point | float | %f |
double floating point | double | %lf |
Char is a Data Type to store a single character. Generaly, char Data Type occupies 1 bytes i.e) 8 bits.
#include <stdio.h> int main() { char a = 'b'; printf("The character of a = %c ",a); return 0; }
Here char data type store a character b in variable a.
Integer is a Data Type to store an integer value. Generaly, Integer Data Type occupies 2 bytes or 4 bytes its highly depend on your operating system bit rates.
#include <stdio.h> int main() { int a = 8; printf("The value of a = %d ",a); return 0; }
Here int data type store an integer value 8 in variable a.
Float is a Data Type to store decimal point values. Generaly, Float Data Type occupies 4 bytes.
#include <stdio.h> int main() { float a = 8.987654321; printf("The value of a = %0.9f",a); return 0; }
Here float data type store an decimal point value 8.987654686 in variable a. Note that float data types precision is limited up to 6 digit after a decimal point. After six digit some garbage value will be displayed by the compiler. %0.9f represent, Display 9 numbers after decimal point.
Double is a Data Type to store decimal point values with more accuracy than float. Generaly, Double Data Type occupies 8 bytes.
#include <stdio.h> int main() { double a = 8.987654321; printf("The value of a = %lf",a); return 0; }
Here double data type store an decimal point value 8.987654321 in variable a with more precision.
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019