Home >Backend Development >C#.Net Tutorial >c language constant definition rules

c language constant definition rules

angryTom
angryTomOriginal
2020-02-20 12:29:0711602browse

c language constant definition rules

C language constant definition rules

Definition of constants: A constant refers to a quantity whose value cannot be changed while the program is running.

Constants in C language can be divided into direct constants and symbolic constants.

Direct constants refer to a form expressed directly with specific data. Direct constants are divided into integer constants, real constants, character constants and string constants;

Symbolic constants are Refers to a constant defined using a C language identifier.

Integer constants are integer constants, including decimal numbers, octal numbers and hexadecimal numbers. For example: 10, 012, 0x0A

Real type constants are also called floating point constants. For example: 3.14, 1.2E-4

Character constants must be enclosed in single quotes. For example: 'M', '\n'

String constants should be enclosed in double quotes. For example: "abc", "a"

Symbolic constants can be represented by macro definitions or by the const keyword. For example: #define PI 3.14 const float PI = 3.14

PHP Chinese website, a large number of programming learning courses, welcome to learn.

The above is the detailed content of c language constant definition rules. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn