C Language Basics 2

Source: Internet
Author: User
Tags alphabetic character arithmetic operators logical operators

◇ data storage and input and output

1. Bits are the smallest storage unit of memory.

2. Every eight bits equals one byte.

3. The highest bit of the byte bit represents the sign, the symbol is 0 is positive, and 1 indicates a negative number. The remaining byte bits represent numeric values.

4. Floating-point numbers are stored in exponential form in computers, which are divided into decimals and exponents.

5. Character: A-Z decimal 65-90 A-Z 97-122 A and a between 32

6. Values are divided into integer types (which can be divided into signed integer variables and unsigned integer variables, the former class stores positive and negative values, the latter can only store 0 and positive values) and floating-point type

Character Char 1 byte-2 of seven-square---2 seven-square minus 1

Short 2 bytes-2 of 15 Square---2 15-time minus 1

integer int long single-precision FLOAT4 byte

Double 8 byte long double 12 byte

* The size of the data type is related to the compiler and hardware platform, but 5 points are ok:

The size of the ^char is one byte

The length of the ^short does not exceed long, which may be equal to

The length of the ^int is not longer than long may be equal to

The length of the ^unsigned equals int

The length of the ^float does not exceed double

7. Data is divided into variables and constants, and constants are divided into literal and symbolic constants.

Literal: integer constant real constant character constant string constant

The escape character is a special character constant:

\ nthe line break

\ t horizontal jump lattice \b backspace \ r return \ \ Backslash character \ ' single quote character ' double quote character

\DDD1 to 3-bit octal number represents the character \xdd1 to 2 hexadecimal digits

8. #define Identifier Constants This is the maintenance of a macro-defined command to facilitate the program (customary identifiers are uppercase letters)

9.** Integer data types and character data types can be assigned to each other.

variable name: begins with an alphabetic character and does not promote the following underscore.       Alphanumeric underlines can be used anywhere.       Unlimited length.     No spaces or non-alphabetic characters are allowed.   cannot be a keyword. Sensitive to case

11. Variables must be initialized with caution: Do not initialize the variable to a value other than the value of its data type.

12. Variables when storing data, note: Be sure to understand the number of bytes occupied by the variable;

Initialize the variables as much as possible when declaring them;

Do not use uninitialized variables;

When storing shaping data, do not use float or double variables, not high efficiency;

Do not assign a value to the unsigned variable.

13.printf formatted output function. The general form is: printf ("Format control string", Output table column)

The format string begins with a "%" followed by a variety of formatting symbols:%d table by decimal integer output,%c by character type output,%ld by decimal long integer output,%f in decimal form

Format string general form: [flag] [Output min width] [. precision] [length] type%6.3f

14.SCANF format input function. The general form is: scanf ("Format control string", Address table column);& fetch address

Specifies the width of the input in decimal integers (scanf ("%5d", &a))

The scanf function has no precision control.

◇ operator-expression statements

1. Expression: Simple expression: A single operand, simple variable, literal, or symbolic constant

Complex expressions: There are several simple expressions, which are linked by operators.

2. Operators:

A. Arithmetic operators: +-x÷%

B. Assignment operator: =

C. Increment and decrement operators are monocular operators, with precedence higher than all binocular operators,

Prefix: ++i indicates that the variable is automatically added 1 before use, suffix: i++ means automatically adding 1,,++ after use-only for integer, character, pointer, and right-to-left binding

D. relational operator: = = equals = = does not equal > < >= <= Binocular

E. Logical operators:&& logic and | | Logic or Binocular! Logical non-monocular right binding

Precedence from high to low:!> arithmetic operators > Relational operators >&& and | | > Assignment Operators

3. Conditional operator: Only one three-mesh operator: expression 1? expression 2: Expression 3

When expression 1 is correct, the value of expression 2 is output, otherwise the output expression 3. Right-associative.

Feeling: Memory is not a lot of things, but also acceptable, but once the synthesis of some difficulties.

C Language Basics 2

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.