answersLogoWhite

0


Best Answer

#include <stdio.h>

int main (int argc, char **argv) {

int i, j, prime;

for (i=51; i<=99; i+=2) {

prime=1;

for (j=3; j<=i-2; j+=2) {

if (i%j == 0) {

prime=0;

break;

}

}

if (prime) printf ("%d ", i);

}

printf ("\n");

return 0;

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

#include<iostream>

#include<vector>

bool is_prime (unsigned num) {

if (n<2) return false; // 0 and 1 are composite

if ((n % 2) 2; // 2 is the only even prime (all others are composite)

// test all odd divisors to see if any are factors of n

for (unsigned d=3; d<=(unsigned)sqrt(n); d+=2) {

if ((n % d) == 0) return false; // d is a factor of n so n is composite

}

return true; // if we get this far, n is prime

}

int main (void) {

std::vector<unsigned> primes;

for (unsigned n=1; n<=100; ++n) {

if (is_prime (n)) primes.push_back (n);

}

std::cout << "There are " << primes.size() << " prime numbers in the range 1 to 100\n";

// ... }

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

There are 25 prime numbers between 1 and 100.
They are: 2 3 5 7 11 13 17 19 23 29
31 37 41 43 47 53 59 61 67 71
73 79 83 89 and 97.
The number 1 57 87 91 and 93 are prime.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Print prime numbers between 1 to 100?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How many prime numbers are between 0-100?

100


How can print prime numbers in between 1-100 but not adjust 40-50 in php language?

Use a counted loop in the closed range [1:100]. If the count is in the closed range [40:50], print the number. For all other numbers outwith this range, only print the number if it is prime.


Are there less prime numbers between 101 and 200 than between 1 and 100?

NO. There are more prime numbers between 1 and 100 than the prime numbers between 101 and 200.number of prime numbers between 1 and 100 = 25number of prime numbers between 101 and 200 = 20


How many prime numbers are between 51-100?

There are ten prime numbers between 51-100.


How many prime numbers are there between 100 and 125?

number of prime numbers between 100 and 125 = 5prime numbers between 100 and 125 = 101,103,107,109,113


What is the sum of the prime numbers between 90 and 100?

The prime numbers between 90 and 100 are 97. To find the sum of prime numbers between 90 and 100, you simply add 97 to get the total sum. Therefore, the sum of prime numbers between 90 and 100 is 97.


What are the prime numbers in between 80-100?

The prime numbers between 80 and 100 are 83, 89, and 97.


How many prime numbers are BETWEEN o to 100?

There are 25 prime numbers between 0 and 100.


How many prime numbers in 1-100?

There are 25 prime numbers between 1 and 100.


What are twin prime numbers between 80 to 100?

Prime numbers between 80 and a 100 are: 83, 89 and 97


How many prime numbers is 1-100?

There are 25 prime numbers between 1 and 100.


What are the prime numbers between 100 and 125?

The prime numbers between 100 and 125 are: 101 103 107 109 113.