C basic statement presentation (on)

C basic statement presentation:

C basic statement presentation:

Part C program is executed by the statements. The function of the program is implemented by executing a statement.
C statements can be divided into the following five categories:
1) expression statement

Adding nothing expression statement by the expression ";" consisting
Its general form: Expression;
execute an expression statement is an expression Calcd ..
For example: x = y + z; assignment statement that is a
2) function call statement

By the function name, the actual parameters plus ";" component.
Its general form: function name (actual parameter table);
execute function calls the function, and the statement is given in the form of actual parameter argument function definition, and then execute the function bodies are transferred in the statement, the function value is obtained.
For example: printf ( "C program") ; calls the library functions, the output string at the beginning of this program Generally, we will add a header file #include <stdio.h> but this function scanf with special functions, sometimes you need to write this sentence can be output.
3) Control statements

Control statements are used to control flow of the program to achieve various structures programmatically. It consists of a particular statement delimiter. There are nine C language control statements. It can be divided into the following three categories:
(1) conditional statement: if statements, switch statements;
(2) perform loop statement: do while statement, while statements, for the statement;
(3) Steering statement: break statement, goto statements, continue statement, return statement.
4) compound statement

A plurality of statements enclosed by brackets {} consisting of a statement called a compound statement. In the program should be a compound statement as a single statement, not multiple statements.
For example:
{
X = Y + Z;
A = B + C;
the printf ( "% D% D", X, A);
}
is a compound statement.
Each statement in the compound statement must be a semicolon ";" at the end, in the parenthesis ")" can not be outside the semicolon.
5) null statement

Only semicolon ";" statements is called a null statement. Empty statement is executed statement does nothing. Statement is used to program the hollow body for air circulation.
For example:
the while (! Getchar () = '\ n-')
{
;
}
function of this statement is that as long as the input from the keyboard is not a carriage return character is output again. Here the loop is an empty statement.

Assignment
1, the initial values in the variable declaration and assignment statements to variable difference:
to the variable initial value is still spaced apart by a comma between the part of the variable after the initial value of other similar variables and the subsequent description of the variables, The assignment you need to use a semicolon.
For example:
int. 5 = A, B, C;
2, when the initial value to a variable, the variable is not allowed to a plurality of successive initial value.
The following description is wrong:
int = A = B = C. 5;
to be written as:
int =. 5 A,. 5 = B, C =. 5;
and continuous assignment allows the assignment statement.
3, the difference between assignments and assignment expression of
an assignment expression is an expression that can appear anywhere allows expression appears, and the assignment can not.
For example:
IF ((X = Y +. 5)> 0) Z = X; is legal
if ((x = y + 5 ;)> 0) z = x; is not legal
because x = y + 5; is statement can not appear in an expression.

Concept of data input and output, and implemented in C language:
Learn what you can:
Here Insert Picture Description
Note: #include <stdio.h> is the system comes with a function
#include "stdio.h" is taken to find a function to write their own

Input and output character data:
the putchar function (character output function): outputs a single character on the display.
Its general form: putchar (the variable characters)
, for example:
the putchar ( 'A';) uppercase A output
and executing the control function for the control characters is no longer displayed on the screen.

Before using this function you must use the file that contains the command:
#include <stdio.h> or #include "stdio.h"

Published 10 original articles · won praise 1 · views 1242

Guess you like

Origin blog.csdn.net/weixin_43671182/article/details/94685777