Identifying prime numbers inputted 10 numbers

I'm sorry if i'm too active here D:
Well, our professor asks us to input ten numbers and the program must output/identify the prime numbers in the given input.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//mycode
#include<iostream>
using namespace std;
void prime_num(int);

int main()
{
	int n[10];
	cout << "Enter 10 numbers: ";
	cin >> n[0] >> n[1] >> n[2] >> n[3] >> n[4] >> n[5] >> n[6] >> n[7] >> n[8] >> n[9];
	void prime_num(int);

	system("pause>0");
	return 0;
}

void prime_num(int n[10])
{
	bool isPrime = true;
	if (n[10] == 1)
		n[10] += 1;
	for (int i = 2; i <= n[10]; i++)
	{
		for (int j = 2; j <i; j++)
		{
			if (i % j == 0)
			{
				isPrime = false;
				break;
			}
		}
		if (isPrime)
		{
			cout << i << endl;
		}
		isPrime = true;
	}
}


Desired Output:
Enter 10 numbers: 1 2 3 4 5 6 7 8 9 10
2 3 5 7

My output:
Enter 10 numbers: 1 2 3 4 5 6 7 8 9 10
//no output TTOTT
1. Use a loop to get 10 numbers.

2. Restructure your code. Create function bool isPrime( int N ) that answers whether number N is a prime. Then use that function.

3. You don't need array.

4. In int array[K] there is no element array[K].
Topic archived. No new replies allowed.