Variables and constants

Source: Internet
Author: User

The path to learning C is long, and today we begin to learn about variables and constants.

Integer variables are used to store integers, and integer variables can be signed, unsigned, long, and short.

long int amount;//-length integer

Long amount;//length integer type

Signed int total;//signed integral type

Signed total;//signed integral type

unsigned int offset;//unsigned integral type

unsigned offset;//unsigned integral type

short int smallamt;//Quick-integer

Short smallamt;//shorter integer type

Floating-point variable: used to store a real number with a decimal number.

Float amount;//Single Precision type

Double bigamount;//dual Precision Type

Long double reallybigamount;//length dual precision type

Character variable

The characters that are stored are characters in the computer's character set.

Char ch;//declares a character-type variable, and the identifier is ch.

A constant is an immutable quantity and is a constant. Constants are integer constants, floating-point constants, character constants, string constants, escape character constants, and address constants.

Integral type constant

Can be long integer, short integer, signed type, unsigned

Floating-point constants

A floating-point constant consists of an integer and a decimal part:

floatnumber=1.6e10f;//signed floating-point type

All floating-point numbers are defaulted to double.

Character-type constants

The value represented is the value that a character variable can contain, and an ASCII expression can be used to represent a character constant or to denote an escape character with a backslash in single quotation marks.

such as ' A ', ' \x2f ', ' \013 ' \x indicates that the following character is hexadecimal, and that the following character is an octal number.

String constants

A string constant is a string of characters enclosed in double quotation marks.

Escape character

\, single quotation mark

\ \ counter Slash

\ n line break

\ r return character

\ t Horizontal tab

The address constant &counter & is the address character that takes the address of a variable or function.

Variables and constants

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.