Introduction to C Language Program first lesson/4

Source: Internet
Author: User

1. Program Notes

Note of the program: is the explanation of the program, to help people who read the code quickly understand the code, easy to work together.

Write program annotations A habit that programmers need to develop.

Issues you should be aware of when writing program annotations:

Comments generally include: ' File name, author, writing time, purpose, remarks '.

General: Important modules are also commented.


2. Memory, CPU, hard disk

Memory: Also known as flash, transient storage.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/F6/wKioL1YvkWniX7ZIAADFqR8Euc4132.jpg "title=" memory. png "alt=" Wkiol1yvkwnix7ziaadfqr8euc4132.jpg "/>

CPU: Data processing, also belongs to the temporary storage.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/F9/wKiom1YvkUuSc1lkAADP_h495Fs194.jpg "title=" Cpu.png "alt=" Wkiom1yvkuusc1lkaadp_h495fs194.jpg "/>

Hard disk: belongs to persistent storage.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/F6/wKioL1YvkZLRzbpiAADN70cv7V0210.jpg "title=" hard disk. png "alt=" Wkiol1yvkzlrzbpiaadn70cv7v0210.jpg "/>


3. Computer hardware (the most original computer)-operating system (to complete the interaction between hardware and users)-application software (applications running in the operating system environment)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/F9/wKiom1YvkXny8HHXAAHwYcvrJTw381.jpg "title=" Operating system. PNG "alt=" wkiom1yvkxny8hhxaahwycvrjtw381.jpg "/>


4.ASCII (America Standard Code for Information Interchange: U.S. Standards for Information interchange codes.

ASCII Code table:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/F6/wKioL1Yvkcrj9L4GAAR0J9Q-DZE273.jpg "title=" ASCII code table. png "alt=" wkiol1yvkcrj9l4gaar0j9q-dze273.jpg "/>

Special characters:

\ nthe line break

\ t transverse jump lattice

\ r Enter

\b Backspace

\ \ counter Slash

Print output: "0A"

printf ("%c", 48); //48 is the ASCII code for "0", where%c represents the output character.

printf ("%c", 65); //65 is the ASCII code for "A", where%c represents the output character.

printf ("%c", 0); //Decide whether to output English characters, mainly "%c" in effect.

printf ("%c", c);


Print output: 48 and 652 digits;

printf ("%d", 48); //%d of which represents the output integer number.

printf ("%d", 65); //6 where%d represents the output integer number.

printf ("%c", 0); //Decide whether to output English characters, mainly "%d" is in effect.

printf ("%c", c);


5. Constants, variables, data types

Constants: The amount of values that can not be changed during a program run.

Variable: The amount of value that can be changed during a program run.

The definition of a variable:

Format: Type + variable name

Naming rules:

Can only be made up of numbers, letters, underscores.

Numbers do not begin.

Can not drink the same keyword, such as: int void return, etc.

Variable names in the C language are case-sensitive.

For example, define variables:

int a = 3; meaning: The variable value 3 is stored in the variable name ' a ' and then stored in the storage unit with the variable address (number).

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/F6/wKioL1YvkiqzhhwJAAF5cF1mKJg632.jpg "title=" Address variable. png "alt=" wkiol1yvkiqzhhwjaaf5cf1mkjg632.jpg "/>


6. Data type

The basic types are: integer, character, and real.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/F9/wKiom1YvkiXQBlXQAAD8LPP4O7Q663.jpg "title=" integral type. png "alt=" Wkiom1yvkixqblxqaad8lpp4o7q663.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/F6/wKioL1Yvkmyjns-LAAJF-CmsEpo751.jpg "title=" Integer table. png "alt=" wkiol1yvkmyjns-laajf-cmsepo751.jpg "/>


The program looks at the number of bytes that long occupies:

printf ("Long =%d\n", sizeof (long));

Character type: Storing characters

The character type takes up one byte, 8 bits, represents the range 0-255, and the range represented is too limited.

Characters commonly used characters:

48-57 0-9

65-90 A-Z

97-122 A-Z

\ nthe line break

\ t transverse jump lattice

\ r Enter

\b Backspace

\ \ counter Slash

Real: Number of digits with a decimal point.

Single-type (float), double type (double), long double type (long doubles)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/F9/wKiom1YvknPQ0olwAAJ5wa7j5f8165.jpg "title=" real type. png "alt=" Wkiom1yvknpq0olwaaj5wa7j5f8165.jpg "/>

7. Conversions between the binaries:

Binary, octal, decimal, hexadecimal are generally included.

Binary: 0, 1

Octal: 0 1 2 3 4 5 6 7

Decimal: 0 1 2 3 4 5 6 7 8 9

Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F

b means binary, o denotes octal, h is hexadecimal, d denotes decimal

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/F6/wKioL1YvksvzbIkKAAG8khJgImA003.jpg "title=" First step. png "alt=" wkiol1yvksvzbikkaag8khjgima003.jpg "/>

How decimal is converted to binary: short Division.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/F9/wKiom1YvkyLSVqz9AABvdZSNjaE226.jpg "title=" Step two. png "alt=" wkiom1yvkylsvqz9aabvdzsnjae226.jpg "/>


The correspondence between binary and octal:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/F9/wKiom1Yvk1uDFWkaAADaW6K2X5I643.jpg "title=" Step three. png "alt=" wkiom1yvk1udfwkaaadaw6k2x5i643.jpg "/>


Binary conversion to octal example:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/F6/wKioL1Yvk7aA5gFgAADMm-2NPDk090.jpg "title=" Fourth step. png "alt=" wkiol1yvk7aa5gfgaadmm-2npdk090.jpg "/>


The correspondence between binary and hexadecimal:


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/F6/wKioL1Yvk-CyUNBhAAFSsycZM7E468.jpg "title=" Fifth step. png "alt=" wkiol1yvk-cyunbhaafssyczm7e468.jpg "/>



Binary conversion to hexadecimal example:

650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/74/F9/wKiom1Yvk9jwaknMAADS1zFIM8I765.jpg " Title= "sixth step. png" alt= "wkiom1yvk9jwaknmaads1zfim8i765.jpg"/>






Introduction to C Language Program first lesson/4

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.