I. Introduction to logical operators
1. Logical operator:&& (with) | | (OR)! (non)
The formula:&& is true, a false is False
|| The truth is true, a false is False
! False is True, True is False
2, we use the following example to see the specific details:
#include <stdio.h>int main (int argc, const char * argv[]) { //define two int type variable int num1=2,num2=3; if (num1>0 && num2>0) { printf ("Num1 and num2&& results are true \ n");//Here is a description of num1,num2 is greater than 0 } if ( Num1>0 && num2<0) { printf ("Num1 is true, Num2 is false, num1&&num2, the final result is false \ n");//Not printed } if ( num1>0 | | num2<0) { printf ("Num1 is true, Num2 is false, num1| | NUM2, the final result is true \ n ");//This will be printed out } if (num1>0) { printf (" Here is true \ n ");//This will be printed } // We can now print out the value of!num1 printf ("%d\n",!num1),//!num1 with a value of 0 if (!num1>0) { printf ("Here is false \ n");//This will not print because num1>0 but the value of!NUM1 is 0 0>0 false } if (!num1==0) { printf ("Here is true \ n");//This will be printed } return 0;}
iOS Development Learning Record the 8th day of C language learning-----logical operators