Today is still watching the tutorial while reading the case study C language ~
Just came to meet a trouble, after watching the curtain friends of the discussion only to find a blind spot of their own do not know!
1. "=": Indicates assignment!! "= =" means equal!!
Force Conversion code type double a=3.14 // define floating-point variable and assign 3.14 to a printf (theinteger portion of "A is%d/n" ( int) a) output: The integer part of a is 3 /* Note: 1, the conversion will not change the original data type and variable value, only in this operation temporarily converted. 2. The result of the cast operation does not follow the rounding principle.
2. Unresolved issues
#include <stdio.h>int main () { int x, y; x = ten; y =-3; printf ("x+y=%d\n", X+y ); printf ("x-y=%d\n", X-y ); printf ("x*y=%d\n", X*y ); printf ("x/y=%d\n", X/y ); printf ("x%%y=%d\n", x%y ); Why this line is preceded by x%%y instead of X%y return 0; } Teacher Answer:% character escape character is percent, want to output% need to use percent.
Similar to line break output to use \ n where \ is the escape character
3. Note: The self-increment and decrement operators change the original value
For example: int x = 0; if: Inx x = 0 printf ("x=%d\n", x + +); printf ("x=%d\n", ++x) printf ("x=%d\n", ++x); printf ("x=%d\n", X + +) outputs the result: 0 2 The output is: 1 1
Law:
3. There are spaces between the symbols in a simple assignment statement, and no spaces between the two consecutive symbols in a compound assignment statement!
For example://Use simple assignment statements to achieve x multiplied by 2.
x = x * 2;
Use a compound assignment statement to achieve y multiplied by 2.
Y *= 2;
Learn the second day of C language!