多线程循环输出abcc++_C ++循环| 查找输出程序| 套装2
多线程循环输出abcc++
Program 1:
程序1:
#include<iostream>
using namespace std;
int main()
{
for(;;)
{
cout<<"Hello ";
}
return 0;
}
Output:
输出:
Hello Hello .... Infinite loop
Explanation:
说明:
In the above code, the loop will execute infinitely. In C++, if we did not mention any condition in the loop then I will consider it as a true. Then the condition will never false, so the loop will never terminate. Then the "Hello" will print infinite times on the console screen.
在上面的代码中,循环将无限执行。 在C ++中,如果我们在循环中没有提及任何条件,那么我将其视为真实情况。 然后条件将永远不会为假,因此循环将永远不会终止。 然后,“ Hello”将在控制台屏幕上无限次打印。
Program 2:
程式2:
#include <iostream>
using namespace std;
int main()
{
for (; EOF;) {
cout << "Hello ";
}
return 0;
}
Output:
输出:
Hello Hello .... Infinite loop
Explanation:
说明:
In the above code, the loop will execute infinitely. In the above code w mentioned EOF in place of loop condition, In C++, EOF is a predefined MACRO, the value of EOF is -1. And as we know that, In C++ any non-zero value is considered as a true for conditions. so the loop will never terminate. Then the "Hello" will print infinite times on the console screen.
在上面的代码中,循环将无限执行。 在上面的代码w中,提到了EOF代替循环条件,在C ++中, EOF是预定义的MACRO, EOF的值为-1。 众所周知,在C ++中,对于条件,任何非零值都被认为是正确的。 因此循环永远不会终止。 然后, “ Hello”将在控制台屏幕上无限次打印。
Program 3:
程式3:
#include <iostream>
using namespace std;
int main()
{
int i = 0;
int a = 10, b = 10;
while (a > b ? 0 : 1) {
i++;
cout << "Hello ";
if (i > 2)
break;
}
return 0;
}
Output:
输出:
Hello Hello Hello
Explanation:
说明:
Here, we declared three local variables i, a, and b with initial values 0, 10, 10 respectively. Here we use a while loop.
在这里,我们声明了三个局部变量i , a和b ,其初始值分别为0、10、10。 在这里,我们使用一个while循环。
Let's understand the condition of a while loop.
让我们了解while循环的条件。
while(a>b?0:1)
In the while loop, we used a ternary operator, here condition (10>10) is false then it returns 1, so the condition for while loop will be true always.
在while循环中,我们使用了三元运算符,此处条件(10> 10)为false,然后返回1,因此while循环的条件始终为true。
In the body of the while loop we used a counter variable i and cout<<"Hello " to print "Hello " on the console.
在while循环的主体中,我们使用了计数器变量i和cout <<“ Hello”在控制台上打印“ Hello” 。
Here "Hello " will be printed 3 times, because the loop will terminate when the value of the variable i becomes 3 that is greater than 2.
此处“ Hello”将被打印3次,因为当变量i的值变为大于2的3时,循环将终止。
Recommended posts
推荐的帖子
C++ Looping | Find output programs | Set 1
C ++循环| 查找输出程序| 套装1
C++ Looping | Find output programs | Set 3
C ++循环| 查找输出程序| 套装3
C++ Looping | Find output programs | Set 4
C ++循环| 查找输出程序| 套装4
C++ Looping | Find output programs | Set 5
C ++循环| 查找输出程序| 套装5
C++ Operators | Find output programs | Set 1
C ++运算符| 查找输出程序| 套装1
C++ Operators | Find output programs | Set 2
C ++运算符| 查找输出程序| 套装2
C++ const Keyword | Find output programs | Set 1
C ++ const关键字| 查找输出程序| 套装1
C++ const Keyword | Find output programs | Set 2
C ++ const关键字| 查找输出程序| 套装2
C++ Reference Variable| Find output programs | Set 1
C ++参考变量| 查找输出程序| 套装1
C++ Reference Variable| Find output programs | Set 2
C ++参考变量| 查找输出程序| 套装2
C++ Conditional Statements | Find output programs | Set 1
C ++条件语句| 查找输出程序| 套装1
C++ Conditional Statements | Find output programs | Set 2
C ++条件语句| 查找输出程序| 套装2
C++ Switch Statement | Find output programs | Set 1
C ++转换语句| 查找输出程序| 套装1
C++ Switch Statement | Find output programs | Set 2
C ++转换语句| 查找输出程序| 套装2
C++ goto Statement | Find output programs | Set 1
C ++ goto语句| 查找输出程序| 套装1
C++ goto Statement | Find output programs | Set 2
C ++ goto语句| 查找输出程序| 套装2
翻译自: https://www.includehelp.com/cpp-tutorial/looping-find-output-programs-set-2.aspx
多线程循环输出abcc++
多线程循环输出abcc++_C ++循环| 查找输出程序| 套装2相关推荐
- 多线程循环输出abcc++_C ++循环| 查找输出程序| 套装4
多线程循环输出abcc++ Program 1: 程序1: #include <iostream> using namespace std; int A = 5; int fun() { ...
- 多线程循环输出abcc++_C ++循环| 查找输出程序| 套装5
多线程循环输出abcc++ Program 1: 程序1: #include <iostream> using namespace std; int main() { int num = ...
- c ++查找字符串_C ++数组| 查找输出程序| 套装5
c ++查找字符串 Program 1: 程序1: #include <iostream> using namespace std; int main() { char* STR[] = ...
- c ++查找字符串_C ++结构| 查找输出程序| 套装2
c ++查找字符串 Program 1: 程序1: #include <iostream> using namespace std; int main() { typedef struct ...
- c ++查找字符串_C ++结构| 查找输出程序| 套装1
c ++查找字符串 Program 1: 程序1: #include <iostream> #include <math.h> using namespace std; str ...
- c ++查找字符串_C ++异常处理| 查找输出程序| 套装1
c ++查找字符串 Program 1: 程序1: #include <iostream> using namespace std; int main() { try { int num1 ...
- c ++查找字符串_C ++结构| 查找输出程序| 套装3
c ++查找字符串 Program 1: 程序1: #include <iostream> #pragma pack(1) using namespace std; typedef str ...
- c ++ 继承_C ++继承| 查找输出程序| 套装1
c ++ 继承 Program 1: 程序1: #include <iostream> #include <string.h> using namespace std; cla ...
- c ++查找字符串_C ++类和对象| 查找输出程序| 套装4
c ++查找字符串 Program 1: 程序1: #include <iostream> using namespace std; class Sample { int X; int* ...
最新文章
- 【Linux】修改/etc/fstab时参数设错,导致启动异常,无法进入系统(已解决)
- [windows server 2008 站点系列五]一招加速域用戶的文件查找速度
- 链表问题8——将单向链表按某值划分成左边小、中间相等、右边大的形式(初阶)
- appium学习【二】:用try捕获异常后,用例的执行结果为pass
- ajax 遍历select 下拉框
- 090_块元素行内元素行内块元素空元素
- 使用diskpart命令为windows7创建分区
- POJ 2955 区间DP必看的括号匹配问题,经典例题
- 分析FLV文件分析和解析器的开源代码
- html判断整数小数点后两位小数点,js控制input框只能输入数字和一位小数点且小数点后面只有两位小数...
- python 处理CSV数据
- 什么是C ??!??!操作员呢?
- Swift面向对象基础(中)——Swift中的方法
- 字节跳动正式offer之前是哪一个环节_不是做梦!她在3天前拿到腾讯、百度、字节跳动的offer!...
- oracle现金流量表逻辑,分析现金流量表填列法的逻辑
- 沃商店运营一周年凸显平台化优势
- HTML小说排行榜案例
- 零极限:创造健康、平静与财富的四句话
- vue 3.0学习1
- 微信小程序原生表格组件