Nth prime number

doubt 1:- Not getting the correct output

doubt 2:- how can I print all elements of vector array in the main function

Hey @aattuull
On line 10 :int temp[…]={1}
Does not initialize ehole array with 1 ,that initializes temp[0]to 1 and rest to 0
So please run a loop to initialize it to 1

Regarding 2nd doubt

for(int i=0;i<prime.size():++i){cout<<prime[i];}

give correct answer but not accepted by coding block ide

also I try your method to print all elements of above vector array which contain prime number but its not working

Hey @aattuull
Did changes in your code :https://ide.codingblocks.com/s/331804
You have to tell nth prime number where for n=500000 ,the prime number
will be of order 10^7 but in your current code you are only checking prime till 500000
So that’s why one case is failing also we cant make local array of that size so declaring it globally

1 Like

Its working ,here printing all the prime nos: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 …

1 Like