C++逻辑运算符

#include <iostream>

using namespace std;

main() {
   int a = 5;
   int b = 20;
   int c ;

   if(a && b) {
      cout << "Line 1 - Condition is true"<< endl ;
   }

   if(a || b) {
      cout << "Line 2 - Condition is true"<< endl ;
   }

   /* Let's change the values of  a and b */
   a = 0;
   b = 10;

   if(a && b) {
      cout << "Line 3 - Condition is true"<< endl ;
   } else {
      cout << "Line 4 - Condition is not true"<< endl ;
   }

   if(!(a && b)) {
      cout << "Line 5 - Condition is true"<< endl ;
   }

   return 0;
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/265434.html

(0)
上一篇 2022年6月7日 19:57
下一篇 2022年6月7日 19:58

相关推荐

发表回复

登录后才能评论