ramylan00
ramylan00 ramylan00
  • 19-12-2020
  • Computers and Technology
contestada

write c++ program from 1to 100 to find prime numbers using statement.​​

Respuesta :

lialeix
lialeix lialeix
  • 19-12-2020

#include <iostream> using namespace std; int isPrimeNumber(int); int main() { bool isPrime; for(int n = 2; n < 100; n++) { // isPrime will be true for prime numbers isPrime = isPrimeNumber(n); if(isPrime == true) cout<<n<<" "; } return 0; } // Function that checks whether n is prime or not int isPrimeNumber(int n) { bool isPrime = true; for(int i = 2; i <= n/2; i++) { if (n%i == 0) { isPrime = false; break; } } return isPrime; }

Answer Link

Otras preguntas

_______ is vesicle-aided transport out of the cell.
When an author introduces the characters and the conflict this is know as
What did president roosevelt say were "perhaps the most vital internal problems of the united states"?
Part A: Factor 3x2y2 − xy2 − 2y2. Show your work. (4 points) Part B: Factor x2 + 6x + 9. Show your work. (3 points) Part C: Factor x2 − 25. Show your work. (
If your workout exceeds an hour, you should substitute _______ for water.
Factor: 15x2+−14x+3 x2 is x to the second power
If a source is trustworthy the source is considered
which part of the body contains enzymes that break down starch into simple sugars?
What did the Spanish believe about the religious views of the American Indians?
What causes lactation in females?