2. C Language Learning ----------- constants and variables in C Language

Source: Internet
Author: User

Constants and variables
1. Variables
(1) variable refers to the amount of variable values that can change while the program is running.
(2) assign an initial value to the variable
Type specifier variable 1 = value 1, variable 2 = value 2 ,......;
2. Constants
In contrast to the definition of a variable, a constant is the amount that cannot be changed while the program is running.
There are five types of constants: integer, real, character, string, and symbolic constant.
 
(1) Integer constants
An integer constant is an integer. It can be a decimal, octal (starting with 0), or a hexadecimal number (starting with 0x or 0X.
(2) real constants
A real constant is also called a floating point constant. It is a value with decimal places. The representation can be decimal or exponential.
(3) scalar Constants
Constant is a character enclosed in single quotes. These characters are generally ASCII characters whose values are the ASCII values of the character.
(4) string constants
String constants are character sequences enclosed by double quotation marks. Character string constants are strictly different from character constants. The Compiler automatically adds an empty character '\ 0' after each character string to indicate the difference.
(5) Symbolic Constants
A symbolic constant is a constant that appears in the form of an identifier. In C, the symbolic constant is defined using the compile preprocessing command # define. the symbolic constant is defined as follows:
# Define constant name value
(6) escape characters
In C, there is also a special character constant, which is a Character Sequence starting with the Backslash "\", called an escape character.
Different from common characters, escape character sequences are not expressed in the literal table but a special ASCII character. Therefore, they can also be expressed using the ASCII value of the character.

From 10-3G-He Jinchao

Related Article

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.