UPDATED:

How To Make A Simple Calculator By C Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... Happy Coding.......... This blog is under construction!!!!
Namecheap.com

Monday, December 26, 2016

Data types and allocation In C


Let's look at the individual data types. In C, a distinction is made between integer and floating-point types. The integer types include char, short int, int, and long int. The floating-point types include float, double, and long double. For each of the 4 integer types, a signed and unsigned variable or constant can be declared. By default, all integer types are signed (signed). This means that you can store both negative and positive numbers. With the keyword signed in front of the type, you can still mark that extra. Whether you are Int i; or Signed int i; Is indifferent. If you only want to store positive integers, you can declare a unsigned type with unsigned: Unsigned int i; The advantage is that unsigned types can represent larger numbers. The reason for this is that for signed types the most significant bit is used as a sign bit. With unsigned, however, it can be used to display the number. By the way, it does not matter if you write long int or long. Likewise, only short can be used instead of short int. The following table lists all data types that you can specify as a type when declaring a variable or constant. The range specifies the smallest and largest possible number that can be stored. The size is the memory space consumption in the working memory.

Integer types:

Char Type:



The long data type often has 8 bytes (64 bits) on 64-bit systems. The size of the integer types is not defined in ANSI-C. But the order is as follows: Char <= short <= int <= long The type short must be at least 2 bytes long and at least 4 bytes large. If you are interested in the exact size on your system, you can look at the limits file header file. It is easier, however, as mentioned, with the sizeof operator.

Floating point types:


Allocation

After a variable has been declared, you can specify the value to store. This process, in which one tells the variable what value to store, is called an assignment.
Example: I = 10; Assume that the variable i is of type int, then the value is assigned to the value 10 (an integer). After this, variable i stores this value. In general it can be said: Variable = value; Instead of variable, you set the identifier of the variable to which you want to assign a value. The assignment operator follows the right of the identifier. The assignment operator ensures that data is "transported" to the variable and signals that it is an assignment. To the right of the assignment operator is the value that the variable should store. This can also be a different variable, then the value of the right variable is assigned to the left variable, ie copied to the left variable. It is always transferred from right to left. IMPORTANT: The assignment operator = is NOT a comparison for equality! The variable, which is on the left, has the right value, but the equality operator (==), which you will get to know later on, must be strictly distinguished from this! The meaning of the = in C is thus different from what you probably know from mathematics. You already know the initialization of variables during their declaration. Here again for the repetition: Type Identifier = value; For example: Int i = 0; If several variables of the same type are agreed, it is also possible to initialize only some of them. An example: Int i, j = 20, k = 100, l; Here, we declare the variables i, j, k, and l. We immediately assign values ​​to the variables j and k, while the others do not. The assignment of constants is very important. Without assignment, constants would be useless. Const int repetitions = 10, mode = 1; Then the constant repeats with the fixed value 10 and the constant mode with the value 1.

Thank you for being with coder mania BD.

No comments:

Post a Comment

Namecheap.com

Popular Posts