---BOOL
BOOL BOOL A=YES; printf ("%d\n", a); A=NO; printf ("%d", a); intA =0, B =0; BOOL result=YES; Result= a >b; printf ("%d\n", result); Result= A = =b; printf ("%d\n", result); Result= (A + b) <= (A-b); printf ("%d\n", result); intA =5, B =8, C =2; BOOL result= a > B && a <C; printf ("result =%d\n", result); BOOL RESULT1= b! = C && a >=C; printf ("Result1 =%d", RESULT1);
---> < = = >= <= With the result is the result of the bool value (only true or false two), both sides of the logical and &&-operator expressions Are true, the result is true, there is a false, that is false, can be understood as well as logic or | | One is true, the return bool value is true, logical non-short-circuit phenomenon, logic and logic, or when the first condition is false, the second condition is not executed, and if the first one is true then the second statement is judged
1 //Logical OR2BOOL result = A = = B | | b >=C;3printf"result =%d\n", result);4 //Logical Non-5BOOL RESULT1 =! (A >c);6printf"Result1 =%d", RESULT1);7 //Short Circuit phenomenon8 intA =5, B =8, C =2 ;9BOOL result = a >= b && + +C;Tenprintf"result =%d", c); One intA =5, B =8, C =2, d =4; ABOOL r = (a >= b && b = = c) | | (A! = B | | b <=d); -printf"r =%d", R);
View Code
-IF Branch Structure if (condition) {statement} If True, execute the following block of statements--if false, jump out, execute a statement block other than if
CharA =0; scanf ("%c",&a); if(A = ='m'|| A = ='M') {printf ("male"); } Elseprintf ("female"); CharA =0 ; scanf ("%c",&a); if(A = = the|| A = =109) {printf ("male"); } Elseprintf ("NV"); printf ("Hello"); intn =0; scanf ("%d",&N); if(N >=0&& N <= -) {printf ("%d within the range", N); } Elseprintf ("%d is not within range \ n", N); printf ("Hello");View Code
Determine if a leap year
//can be divisible by 400 or 4 but not divisible by 100 . intA =0; scanf ("%d",&a); ifA -==0|| A4==0&& A% -!=0) {printf ("Run"); } Elseprintf ("NO");
->switch (int expression) Case syntax->swich can only be an expression with an integral structure->case can only be followed by a constant (integer constant or character constant)->break to jump out of the entire switch case The value of->case cannot be repeated--if there is no corresponding case, you will need to add {} If you want to define a variable in the default->case
1 intTelnumber =0;2scanf"%d",&telnumber);3printf"extension number is%d\n", telnumber);4 Switch(telnumber) {5 Case 1:6printf"1");7 Break;8 Case 2:9printf"2");Ten Break; One Case 3: Aprintf"3"); - Break; - Case 4: theprintf"4"); - Break; - Case 5: -printf"5"); + Break; - Case 6: +printf"6"); A Break; at default: -printf"No"); - Break; - } -printf"\nduang!!!!! Analysis Complete");View Swich
Condition operator (trinocular operator)-conditional expression? Expression: expression If the conditional expression is true, the result before the colon is taken, and if false, the result behind
int 0 0 ; scanf ("%d%d", &a, &b); int 0 ; = (A > B)? A * a:b * b; printf (" Max is%d", Max);
C Language Learning-The basic point of knowledge