answersLogoWhite

0

#include <iostream>

bool isPrime(int p)

{ if( p<=1 ( p>2 && p%2==0 ))return( false );int max = (int)sqrt(( double ) p ) + 1;for( int i=3; i<=max; i+=2 )if( p%i==0 )return( false );return( true );

}

int main()

{ int primes[10];

int count=0, num=0;

while( count!= 10 )

{num+=num>2?2:1;if( isPrime(num) )primes[count++]=num;}for( int i=0; i<10; ++i )std::cout << primes[i] << std::endl;return( 0 );

}

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

Consider prime numbers between 1 and 10000. Draw a flowchart to display the prime numbers.Write a pseudo code associated with the flowchart in a)?

A) Here's an example of a flowchart and pseudocode that could be used to display the prime numbers between 1 and 10000: Flowchart:
START Set up an array of numbers from 1 to 10000 Set an empty array to store the prime numbers Set i = 2, the first prime number For each number in the array, check if it is divisible by i If it is divisible by i, it is not a prime number and move to the next number in the array If it is not divisible by i, it is a prime number and add it to the prime numbers array Increase i by 1 and go back to step 4 Repeat steps 4 through 7 until i is greater than the square root of 10000 Display the prime numbers array END


What is the term used to describe numbers that can only make 1 array?

They are prime numbers.


How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


How are all the area model of the prime numbers similar?

They only have one array.


What do you call numbers that can't be arranged into two rows of a array?

We call them prime nunberds


Why do prime numbers only have one array?

Because they only have one factor pair.


How do you write a VBnet program to find the prime numbers between 100 to 200?

VBnet program to find the prime numbers between 100 to 200?


Write a program to print first 100 alternative prime numbers?

This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.


What is a prime number tree?

a type of array for prime and composite numbers. it is a tree which is divided into smaller and smaller prime numbers. usually at the end of the prime tree there is 2 or more (preferably less than 10) numbers. those numbers usually include 2,3,5,or7


What are the first three prime numbers?

The first three prime numbers are 2,3 and 5.


What are the first twenty six prime numbers?

The first 26 prime numbers 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,97and 101


What is the sum of the first 250 prime numbers?

The sum of the first 250 prime numbers is 182,109.