1. Classification
of
C
statements:
① Control statement: two branch statements (
if-else
,
switch
), three loop statements (
for
,
while
,
do
-
while
), four transfer statements (
continue
,
break
,
goto
,
return
)
② Function call statement such as:
printf("Hello, world!");
③Expression statement such as:
x+y;
i++; a=2; a=3*5, 40 ;
④ Empty statement
;
⑤Compound statement
{
sequence of statements
}
2. Assignment statement: The assignment statement is composed of an assignment expression plus a semicolon, such as:
b=3;
3. The concept of data input and output and its realization in
C
language
7
Time allocation and notes
Hands-on experiments, simple learning
Single C programming
Baidu library
-
let everyone improve themselves equally
1.
The so-called input and output is based on the computer host.
2.
The C language itself does not provide input and output statements, and the input and output operations are implemented through function calls.
Now.
3.
To use the C language library function, use "#include" to include the relevant header files to the user
source program.
4. Input and output of character data
1.
Character output function -
putchar
Syntax:
putchar(c)
Semantics: output a character (to the
stdout terminal);
2.
Character input function -
getchar
Syntax:
getchar ( )
, is a function without parameters;
Semantics:
(
from the
stdin
terminal
)
input a character, the value of the function is obtained from the input device
character of.
5. Format input and output
1.
Format output function -
printf
Syntax:
printf ("
format control
",
output table column
)
;
Format control: it is a string enclosed in double quotes, which contains two kinds of information: ⑴ ordinary characters
and escape characters (such characters are always output as they are) (2) format specification: composed of
%
and format control characters
composition. Such as:
%d, %f,
etc.; (
P77
) such as:
printf(“a=%d, b=%d”, a, b);
if
a
,
b
The values are 2
and
3
respectively
, then the output result is:
a=2, b=3