Write+a+program+to+find+all+prime+numbers+between+100+and+200.C
时间: 2023-12-10 17:04:46 浏览: 76
```c
#include <stdio.h>
int main() {
int i, j, flag;
printf("Prime numbers between 100 and 200 are: ");
for (i = 100; i <= 200; i++) {
flag = 0;
for (j = 2; j <= i / 2; j++) {
if (i % j == 0) {
flag = 1;
break;
}
}
if (flag == 0) {
printf("%d ", i);
}
}
return 0;
}
```
--相关问题--:
1. 请问什么是质数?
2. 如何判断一个数是否为质数?
相关问题
Write+a+program+to+find+all+prime+numbers+between+100+and+200.C++
以下是C++语言的程序,用于查找100到200之间的所有质数:
```c++
#include <iostream>
using namespace std;
int main() {
int i, j;
bool isPrime;
cout << "Prime numbers between 100 and 200 are: " << endl;
for (i = 100; i <= 200; i++) {
isPrime = true;
for (j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
cout << i << " ";
}
}
return 0;
}
```
Write+a+program+to+input+the+ten+quiz+grades+and+count+passes+and+failures.+Then+print+a+summary+of
以下是Python程序,用于输入十个测验成绩并计算通过和失败的数量,并打印摘要:
```python
passes = 0
failures = 0
student_counter = 1
while student_counter <= 10:
result = int(input("Enter result (1=pass, 2=fail): "))
if result == 1:
passes += 1
else:
failures += 1
student_counter += 1
print("Number of passes:", passes)
print("Number of failures:", failures)
if passes > 8:
print("Raise tuition")
```
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![cpp](https://img-home.csdnimg.cn/images/20210720083646.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)