c++ cdi+示例_C ++“或”关键字示例
c++ cdi+示例
"or" is an inbuilt keyword that has been around since at least C++98. It is an alternative to || (Logical OR) operator and it mostly uses with the conditions.
“ or”是一個內置關鍵字,至少從C ++ 98起就存在。 它是||的替代方法 ( 邏輯OR )運算符,它通常與條件一起使用。
The or keyword returns 1 if the result of at least one operand is 1, and it returns 0 if all operands result is 0.
如果至少一個操作數的結果為1,則or關鍵字返回1;如果所有操作數的結果為0,則or關鍵字返回0。
Syntax:
句法:
operand_1 or operand_2;Here, operand_1 and operand_2 are the operands.
在這里,操作數_1和操作數_2是操作數。
Example:
例:
Input:a = 10;b = 20;result = (a==10 or b==30);Output:result = 1演示使用“ or”關鍵字的C ++示例 (C++ example to demonstrate the use of "or" keyword)
// C++ example to demonstrate the use of // 'or' operator.#include <iostream> using namespace std;int main() {int num = 20;if (num >= 10 or num <= 50)cout << "true\n";elsecout << "false\n";if (num >= 20 or num <= 50)cout << "true\n";elsecout << "false\n";if (num > 50 or num <= 100)cout << "true\n";elsecout << "false\n";return 0; }Output:
輸出:
true true true翻譯自: https://www.includehelp.com/cpp-tutorial/or-keyword-with-example.aspx
c++ cdi+示例
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的c++ cdi+示例_C ++“或”关键字示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python创建空元组_用Python创
- 下一篇: matlab中now函数_now()方法