Write a program in C++ to check the input number is prime or not OR to generate between 100 to 200?
Answers
Answered by
0
Answer:
HERE IS THE ANSWER
Explanation:
#include <iostream>
using namespace std;
int main() {
int low, high, i;
bool isPrime = true;
cout << "Enter two numbers (intervals): ";
cin >> low >> high;
cout << "\nPrime numbers between " << low << " and " << high << " are: " << endl;
while (low < high) {
isPrime = true;
if (low == 0 || low == 1) {
isPrime = false;
}
else {
for (i = 2; i <= low / 2; ++i) {
if (low % i == 0) {
isPrime = false;
break;
}
}
}
if (isPrime)
cout << low << " ";
++low;
}
return 0;
}
Similar questions
Social Sciences,
8 days ago
History,
8 days ago
Math,
8 days ago
Biology,
16 days ago
Social Sciences,
9 months ago
English,
9 months ago