The printf function and the scanf function are defined in the header file stdio.h, so add # include <stdio.h> when using the scanf function. Second, the printf function 1. Definition: the printf () function is a formatted output function, generally used to output information to the terminal in the specified format; 2. Format: printf ("XXXXXXXX"); three, scanf function 1. Definition: the scanf () function enters data into the specified variable from the keyboard in a user-specified format; 2. Format: scanf ("%d", &number); The address of the &number variable 3. Attention Point
- The SCANF function accepts only the address of the variable;
- The scanf function is a block-type function that waits for user input;
- Once the user has entered, the value entered by the user is assigned to the corresponding variable
- The scanf function cannot use \ n in the first argument: scanf ("%d\n", &number);
Four, code practice 1. Practice One:
Operation Result:
2. Practice the results of the second operation:
Black Horse Programmer----printf function and scanf function