Two level C language preparation knowledge point induction

Source: Internet
Author: User
Tags arithmetic arithmetic operators

Written in the beginning: Before the computer has not been two levels, now with more programming language, want to September together to the level two three.

Chapter One basic concepts of programming

1. Procedure : A series of instructions designed to solve a problem can be recognized and executed by the computer.

program = syntax + algorithm.

2. Programming language : A type of medium and tool for exchanging information when people interact with computers, consisting of statements.

The program consists of the following steps:

(1) Determine the data structure: according to the requirements of the task book, the specified input data and output structure, determine the storage data structures.

(2) Determine the algorithm: for the data structure to determine the resolution of the problem, the steps to complete the task.

(3) Coding: According to the determined data structure and algorithm, using the selected computer language to write code, input to the computer and saved on disk, abbreviated programming.

(4) Debug the program on the computer.

(5) Collate and write documentation.

3. Algorithm: specific methods and steps to solve the problem

The five properties of the algorithm:
(1) Poverty--can be completed within a reasonable range (not a cycle of death)

(2) certainty--no ambiguity

(3) Feasibility--through a finite number of basic operations can be completed

(4) 0 or more inputs

(5) has one or more outputs

4. Description of the algorithm: pseudo-code and flowchart (general flowchart and N-S flowchart)

As shown, the left side of the general flowchart, the right is the N-S flowchart.

5. Structured Programming and modular architecture

Structured programs: procedures for using the three structures of order, selection, and cycle

Common features of three basic structures:

(1) Only one entrance

(2) Only one exit

(3) Every part of the structure has the opportunity to be executed to

(4) There is no "dead loop" within the structure.

Modularity: Dividing a complex problem into small problems and solving them in a single way

C language is modularized by function dividing function.

Chapter II Preliminary knowledge of C programming

1. Composition and format of simple C language Program

#include <stdio.h>  //stdio.h I means that input,o represents output,h for head;  The return value type  of the int main ()//int function Main () principal function     , which is the starting position of the program execution entry address {//function int width=3, height=4;//     define variable int area=width*height;     printf (" =%d\n", area); %d is the format control character, decimal     integer return0;} Where the function ends

Line comment: Explain, remove statements that you do not want to execute temporarily

/* */Paragraph comment

#include <stdio.h> is the content to be processed before the program compiles, called the Compile preprocessing command. There are many more pre-processing commands, and they all start with the "#" sign, and do not end with semicolons.

Stdio.h is the header file of the C language for the output stream of the standard input stream.

When using input and output functions in a standard library, the compilation system asks the program to provide information about the input and output functions, #include <stdio.h> is used to provide this information, Stdio.h is a file name provided by the C compiler system, and Stdio is the abbreviation for "Standard Input&output", which is information about the standards input and output.

Pre-processing commands, called file-containing commands, are included in the stdio.h of some of the information files that the program needs to use for the system-defined function printf () before compiling. A file with a suffix of ". h" is called a header file.

2. Identifiers, constants, and changes

(1) Identifier: The name of the action object and the character with special meaning are marked in programming

Identifiers include: Keywords (reserved words), predefined identifiers, user identifiers

Key Words: The C language has pre-defined a number of identifiers, which represent fixed meanings in the program and cannot be used for other purposes , and these identifiers are called keywords. Including:

auto--declares an automatic variable, by default the compiler generally defaults to auto

int--declaring integer variables

double--declaring double-precision variables

long--declaring long shaping variables

char--declaring a character-type variable

float--declaring floating-point variables

short--declaring a short-integer variable

signed--declaring a signed type variable

unsigned--declaring unsigned type variables

struct--declaring struct-body variables

union--declaring federated data types

enum--declaring enum types

static--declaring static variables

switch--for switch statements

case--Switch Statement Branch

The "other" branch in the default--switch statement

break--jump out of the current loop

register--declaring a Register variable

const--declaring read-only variables

volatile--Description variables can be implicitly changed in program execution

typedef--used to alias data types (there are other effects)

extern--reference variable

return--subroutine return statement (can take parameters or without parameters)

void--declaring a function with no return value or no argument, declaring a null type pointer

continue--end the current loop and start the next cycle

Loop body of do--Loop statement

Loop condition for while--loop statements

if--conditional statements

else--Conditional Statement Negation branch (with IF)

for--a cyclic statement

goto--Unconditional Jump Statement

sizeof--Calculate the amount of memory space the object occupies

predefined identifiers : Identifiers that are pre-defined in the C language and have special meanings, such as printf, scanf, sin, isalnum, and so on

A predefined identifier can be used as a user identifier, except that it loses the intended intent of the system, and improper use also causes the program to fail.

user identifiers: also called Custom identifiers, which are identifiers defined by the user according to their needs.

Rules:

A, can only contain alphanumeric underlines

B, can only start with a letter or an underscore

C. Keywords cannot be used

Correct: Area, PI, _int, A_array, s1234, p101

Illegal: 456p, cade_y, W.W, a&b

3. Variables and Constants

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

int width;

int height;

In C language, variables are defined before they can be used

Variables have variable names, variable addresses, variable values, data types four properties

Constant: The amount of value that cannot be changed during a program's operation

such as: "Hello world! ", 3, ' A ', 3.14

Symbolic constants: a symbol that replaces a constant with a symbol is called a constant symbol.

int const NUM=5

#define N 5

4. Data type

Integral type data

(1) Decimal means: decimal is represented by a serial number [0-9]. Example 345 67899 0-2467 only decimal can be negative

(2) octal means: A sequence of sequential numbers starting with the number 0, which can only have 0-7 of these eight digits. Example: 045 076 067456, while 019, 423 are illegal octal numbers.

(3) hexadecimal means: a sequence of consecutive numbers and letters beginning with 0 x or 0x, with only 0-9, a-f, and a-f numbers and letters in the sequence, with letters A, B, C, D, E, and F respectively corresponding to 10, 11, 12, 13, 14, 15, and uppercase or lowercase.

Integer variable

It can be divided into basic type, short integer type, long integer type and unsigned type four kinds.

Name Full name type specifier Bytes Range
Integral type [Signed] int 4 -2147483648 to 2147483647
Unsigned integral type unsigned [int] 4 0 to 4294967295
Short-integer [Signed] short [int] 2 -32768 to 32767
unsigned short integer type unsighed short [int] 2 0 to 65535
Long integer type [Signed] long [INT] 4 -2147483648 to 2147483647
unsigned long integer type unsigned long [int] 4 0 to 4294967295

5. Real-Data

Real constants: Also known as real numbers or floating-point numbers.

1. Decimal form: Consists of a number and a decimal point, must have decimal points.

For example: 4.23, 0.15,. 56, 78., 0.0,

2. Exponential pattern: In the form of a power, the letter E or e followed by a power of 10.

The letter E or E must be preceded by a number, and the exponent following the letter E or E must be an integer, with no spaces between the front and back of the letter E or E and the number (the real variable also follows this principle).

For example: 2.3e5, 200e-2, 0.5E3, 4.5e0, and E4,. 5e3.6,. e5, e are not legal.

Real variables

1. Single precision: float for the keyword

The general form of the definition float A, b, C;

float a=4.5, b=5.6;

Note: (1) accounted for four bytes 32 bits

(2) 7-digit valid digital -1038~1038

2. Double: the keyword is double

The general form of the definition double a,b,c;

Double a=5.9, b=45.36

Note: (1) accounted for eight bytes 64 bits

(2) 15~16-bit effective digital -10308~10308

Description

A. In memory, real numbers are stored in exponential form

B. In memory, integers can be stored accurately and real data has errors

C. You can assign an initial value while defining a variable.

Summarize:

1.C languages are case-sensitive

2. Classification of constants: integer constants, real constants, character constants, string constants

3. Categories of variables: 1. Integer variables: Basic, short, long, and unsigned four

2. Real variable classification: single-precision, double-precision

4. Exponential form: The letter E or E must be preceded by a number, and the letters E and E after the exponent must be an integer, the letter E or E before and after and the number must not have a space (the real variable also abide by this rule)

6. Arithmetic expressions

Arithmetic operators: + 、-、 *,/,%, ()

Assignment expression: =

Composite copy expression: + =,-=, *=,/=,%=

Self-increment, auto-subtract: + + 、--symbol budget character

The comma operator and the comma expression: expression 1, expression 2, expression 3, ..... Expression n

Two level C language preparation knowledge point induction

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.