Computer Science, asked by kumarimadhu99935, 16 days ago

Write a program in C++ to check the input number is prime or not OR to generate between 100 to 200?​

Answers

Answered by Princekuldeep
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