[Learning notes] [C Language] constant, learning notes constant

Source: Internet
Author: User

[Learning notes] [C Language] constant, learning notes constant
1. What is a constant?

Constant, indicating some fixed data

2. Constant Classification

1> integer constant (int)

Contains all integers, such as 6, 27, 109, 256,-10, 0, and-289.

2> float type constant (float \ double)

* Float constants are classified into double and float data types.

Double: double float type, which is actually decimal. For example, 5.43,-2.3, and 0.0 (note that 0.0 is a decimal number)

Float: Single-precision floating point type, which is also a decimal point, which is less accurate than double, that is, it can represent less decimal places. To distinguish it from double, float data ends with f, such as 5.43f,-2.3f, and 0.0f. Note that the 10f format is absolutely not supported. the compiler will directly report an error and only allow f to be added to decimal places.

3> character constant (char)

Convert a number (0 ~ 9), English letters (~ Z, ~ Z) or other symbols (+ ,-,! ,? And so on. For example, '6', 'A', 'F', '+', and '$.

Note: single quotes can only contain 1 character and cannot contain Chinese characters. The following statements are incorrect: 'abc', '123', and 'mal'

4> string constants

Enclose one or more characters in double quotation marks ("") to form a String constant.

For example, "6", "male", "Wow haha", "abcd", and "my_car4", in fact, printf ("Hello World"); "Hello World" in the statement is a String constant.

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.