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

Mark breaks up a 9 hour. Drive into three segments.he drives 2 1/2 hours before stopping for lunch. After driving some more,he stops for gas.if the second segme
I am probably the worst at math ive tried everything on this problem somebody plz help
the half life of an isotope X is 3 days how long will it take for 1/2 of a 10 G sample to decay
As governor, I understand a healthy economy is dependent upon a healthy environment. Florida’s residents and businesses rely on clean water, clean air and open
what is 15:3 in simplist form
How do I add and subtract fractions?
Help me guys i need your support
The endosymbiotic theory proposes that mitochondria in eukaryotic cells arose from
Mrs. Hamilton worked for a real estate agency. She sold a house for $175,000. The agency’s fee for the sale was 4% of the sale price. Mrs. Hamilton received $4
HALP MEH ON DIS YO 72 PIONTS