Here, blue will have a value of 6 because each name will be one greater than the one that precedes it. For example, in the following enumeration, green will have the value 5. Integer We use these for storing various whole numbers, such as 5, 8, 67, 2390, etc. Here are the five primitive or primary data types that one can find in C programming language: 1. In C language, four different data types can be used to differentiate and store various types of data. But you can give a name, a specific value by adding an initializer. The basic data types are also known as the primary data types in C programming. Whereas, the marks of a student would require a data type that can store decimal values. Finally, c is assigned the value "blue".īy default, the value of the first name is 0, the second name has the value 1, and the third has the value 2, and so on. The list of names is comma separated.įor example, the following code defines an enumeration of colors called colors and the variable c of type color. C provides several basic data types that you can use to declare variables. Here, the enum-name is the enumeration's type name. The general form of an enumeration type is −Įnum enum-name var-list Each enumerator is a constant whose type is the enumeration.Ĭreating an enumeration requires the use of the keyword enum. The memory size of basic data types may change according to 32 or 64 bit operating system. Now, the following declaration is perfectly legal and creates an integer variable called distance −Īn enumerated type declares an optional type name and a set of zero or more identifiers that can be used as values of the type. C++ Data types for beginners and professionals with examples on constructor, if-else, switch, break, continue, comments, arrays, object and class, exception, static. Following is the simple syntax to define a new type using typedef −įor example, the following tells the compiler that feet is another name for int − In addition to these there few more data types in Embedded C. They are used as prefixed to the basic data types. There are many data types in C Programming Language like signed int, unsigned int, signed char, unsigned char, float, double, etc. In C, we have 4 data type modifiers that are used to modify data types. You can create a new name for an existing type using typedef. Data Types in C Programming Language (or any programming language for that matter) help us declaring variables in the program.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |