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

-1/4 x + 10=7 show work
Just answer and I will give points 30 points
can anyone help me with my history homework?​
Prompt: In one to two paragraphs, explain how the Industrial Revolution led to the need for reformbrainliest for best answer!! 25 points too!​
pls complete it (picture)​
What are some achievements of Egypt's greatest pharaohs?
IMPORTANT!1! DUE TOMORROW Explain how 38 ATP are produced through the process of aerobic cellular respiration. Be sure to include the major energetic events in
The flower garden is a square with sides of 16 feet. How many feet long will the path be Recall the Pythagorean Theorem for right triangles, that the sum of the
.Capital, a business magazine, collected $480,000 in subscription revenue on May 31. Capital earns a minimum of $351,000 from the buyers who are not the subscri
y=-3x2 + 18x + 10 what is the axis of symmetry step by step?