Naming rules for data types, variables

Source: Internet
Author: User

1, Integer type:

By default, integer variables declared in the C language are signed, that is, the left-most reserved sign bit, and if you do not need to use the symbol bit, you need to declare the unsigned type. Unsigned integers are used primarily for system programming and underlying machine-related applications.

unsigned (unsigned) and signed (signed) can decorate integer and floating-point and char types, unsigned include 0 and positive numbers (no negative numbers), signed include negative numbers, 0, positive numbers.

On a computer with different CPU bits, the range of values for each integer type is the following table:

  

2. Floating-point type

There are three floating-point types available in the C language:

FLOAT: single-precision floating-point number. It is suitable for the representation of the decimal number which is not much required for precision;

Double: two-precision floating-point number. Provide a more accurate representation of the data;

Long double: extends the precision floating point number. Very high accuracy, low probability of use; (understanding)

The value range of floating-point types refers to the following table:

  

    • Floating-point Constants Description:

A floating-point constant must contain a decimal point or exponent, where the exponent indicates the power of 10 to scale the preceding number. By default, the floating point constant is stored in double precision, meaning that when the C language compiler encounters a float constant in the program, it is stored in memory with a double type value, and the double type value does not cause any problems when it is converted to the float type. In some cases, to explicitly identify a numeric value, or to force the compiler to handle a numeric value by a data type, we need to explicitly increment the tag after the numeric value to clarify the type of processing for the constant. For example: 57.0F, 57.0f and so on.

3. Character Type:

The character type takes up 1 bytes in memory, and the character variable can be used for any single assigned value, which needs to be amplified by the literal constant. Each character corresponds to a decimal value in the ASCII code table, and the C language allows the characters to be used as integers and participate in the operation.

4. Naming rules for variables:

Variable names can only be composed of letters, numbers, and falling lines, in addition to other special characters (such as: control characters, special symbols, etc.);

The variable name must start with a letter or an underscore;

Reserved words in C language have special meanings and cannot be used as variable names;

The C language variable names are case-sensitive, for example: variable A and variable A are two different variables.

Naming rules for data types, variables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.