c++ cdi+示例

"and" is an inbuilt keyword that has been around since at least C++98. It is an alternative to && (Logical AND) operator and it mostly uses with the conditions.

“ and”是一个内置关键字,至少从C ++ 98起就存在。 它是&& ( 逻辑AND )运算符的替代方法,它通常与条件一起使用。

The and keyword returns 1 if the result of all operands is 1, and it returns 0 if the result of any condition is 0.

如果所有操作数的结果均为1,则and关键字将返回1,如果任何条件的结果为0,则它​​将返回0。

Syntax:

句法:

    operand_1 and operand_2;

Here, operand_1 and operand_2 are the operands.

在这里,操作数_1和操作数_2是操作数。

Example:

例:

    Input:
a = 10;
b = 20;
result = (a==10 and b==20);
Output:
result = 1

演示使用“ and”关键字的C ++示例 (C++ example to demonstrate the use of "and" keyword)

Example 1:

范例1:

// C++ example to demonstrate the use of
// 'and' operator.
#include <iostream>
using namespace std;
int main()
{int num = 20;
if (num >= 10 and num <= 50)
cout << "true\n";
else
cout << "false\n";
if (num >= 20 and num <= 50)
cout << "true\n";
else
cout << "false\n";
if (num > 50 and num <= 100)
cout << "true\n";
else
cout << "false\n";
return 0;
}

Output:

输出:

true
true
false

Example 2:

范例2:

// Input name, age, height and weight
// check you are eligible for the
// army selection or not?
#include <iostream>
using namespace std;
int main()
{string name;
int age;
float height, weight;
cout << "Enter name: ";
cin >> name;
cout << "Enter age: ";
cin >> age;
cout << "Enter height (in cm): ";
cin >> height;
cout << "Enter weight (in kg): ";
cin >> weight;
if (age >= 18 and height >= 165 and weight >= 55)
cout << name << " , you're selected.";
else
cout << name << " , you're not selected.";
return 0;
}

Output:

输出:

RUN 1:
Enter name: Shivang
Enter age: 23
Enter height (in cm): 172
Enter weight (in kg): 67
Shivang , you're selected.
RUN 2:
Enter name: Akash
Enter age: 19
Enter height (in cm): 157
Enter weight (in kg): 70
Akash , you're not selected.

翻译自: https://www.includehelp.com/cpp-tutorial/and-keyword-with-example.aspx

c++ cdi+示例

c++ cdi+示例_C ++“和”关键字示例相关推荐

  1. c++ cdi+示例_C ++“或”关键字示例

    c++ cdi+示例 "or" is an inbuilt keyword that has been around since at least C++98. It is an ...

  2. c++ cdi+示例_C ++'not'关键字和示例

    c++ cdi+示例 "not" is an inbuilt keyword that has been around since at least C++98. It is an ...

  3. c++ cdi+示例_C ++中带有示例的本地类

    c++ cdi+示例 C ++中的本地类 (Local Class in C++) In C++, generally a class is declared outside of the main( ...

  4. java 示例_Java最终关键字示例

    java 示例 The final keyword in Java can be used with variables, methods, and classes. Java中的final关键字可以 ...

  5. c语言 函数的参数传递示例_C ++中带有示例的nearint()函数

    c语言 函数的参数传递示例 C ++附近的int()函数 (C++ nearbyint() function) nearbyint() function is a library function o ...

  6. 关键字驱动测试示例_带有示例的False关键字

    关键字驱动测试示例 Python False关键字 (Python False keyword) False is a keyword (case-sensitive) in python, it i ...

  7. python 示例_Python中带有示例的关键字除外

    python 示例 Python关键字除外 (Python except keyword) except is a keyword (case-sensitive) in python, it is ...

  8. scala语言示例_标有示例的Scala关键字

    scala语言示例 Scala | 任一关键字 (Scala | Either Keyword) Either is a container similar to the option which h ...

  9. python 示例_Python中带有示例的class关键字

    python 示例 Python类关键字 (Python class keyword) class is a keyword (case-sensitive) in python, it is use ...

最新文章

  1. TensorFlow学习笔记(二十三)四种Cross Entropy交叉熵算法实现和应用
  2. Godaddy如何导入导出MSSQL数据库
  3. 浏览器窗口的高度和宽度
  4. python 将pdf分页后插入至word中
  5. 本地配置DNS服务器(MAC版)
  6. .net core 引用jar_Python一键转Jar包,Java调用Python新姿势!
  7. mysql not in优化_实践中如何优化MySQL(收藏)
  8. CSS3动画 - title下划线的拉伸效果
  9. 文字加减前后缀lisp_日本搞笑艺人催泪讲授汉字课堂告诉你文字背后的意义!...
  10. python中函数的返回值
  11. Gym 100633G Nano alarm-clocks
  12. matlab的图像滤波,Matlab实现图像滤波
  13. 西游释厄传 所有物品代码
  14. ffmpeg录制麦克风声音和pc内部声音(如播放歌曲)---混音--修正
  15. 电路设计软件系列教程(五),Protel DXP电路设计软件之设计规则(上)
  16. STM32 四相电机驱动板ULN2003 驱动
  17. 1247:河中跳房子
  18. java写到txt乱码_java读取txt文本发生乱码的解决方法
  19. 手机怎样转换php格式,手机视频格式转换方法适合所有手机视频格式转换|如何转换手机视频格式...
  20. 联想计算机如何设置用户名和密码忘了,联想电脑怎么设置密码

热门文章

  1. 电感发出声音怎么解决_如何解决多层PCB设计时的EMI
  2. daocloud创建mysql_GitHub - DaoCloud/php-apache-mysql-sample
  3. CPU缓存越大计算机的性能越好,CPU缓存真的越大越好?小心你的钱包
  4. python类继承中构造方法_第8.3节 Python类的__init__方法深入剖析:构造方法与继承详解...
  5. 非常酷!10个基于 HTML5 的字体应用演示网站
  6. Riot - 比 Facebook React 更轻量的 UI 库
  7. 洛谷P1099 树网的核
  8. C#线程 ---- 线程同步详解
  9. loadView的使用总结
  10. ubuntu 开发板ping通虚拟机挂载nfs服务器