While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.
C has various data types to store data in program. C program can store integer, decimal number, character(alphabets), string(words or sentence), list etc. using various data types. We need to specify the data type of variable(identifier) to store any data in it. Explanation and basic usage of the concept is provided below. Data types and Modifiers have significant in-depth technical details which are not covered in this article. There are 2 categories of Data Types in C:
These data types store fundamental data used in the C programming.
int myIntegerValue = 100;
char myCharacter = 'A';
Note: Every character has a corresponding ASCII value to it ranging from -128 to 127. Numbers as a character has their corresponding ASCII values too. For example, ‘1’ as char has ASCII value 49, ‘A’ has ASCII value 65.6. float It stores real numbers with precision upto 6 decimal places. It takes 4 bytes of memory and is also known as floating point number.
float myFloatingValue = 100.6543;
double myDoubleValue = 180.715586;
These are made by collection or combination of primitive data types and hence known as derived data types. Details will be covered in the articles dedicated to each topic of the following:
These are keywords in C to modify the default properties of int and char data types. There are 4 modifiers in C as follows.
short int myShortIntegerValue = 18;
long long myLongIntegerValue = 827337203685421584;
signed int myNegativeIntegerValue = -544; signed int mypositiveIntegerValue = 544; /* Both of the statements have same meaning even without "signed" modifier*/
unsigned int myIntegerValue = 486;
It is important to understand the basic usage of data types to code and develop logic. There is a lot more about data types, however, you can easily proceed in your journey to C programming with the information provided.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.