Calculate Nth Prime Number

Problem - https://hack.codingblocks.com/contests/c/537/52
My Code - https://ide.codingblocks.com/s/37577

The code is running in IDE but shows runtime error in the contest in some cases and Time Limit exceeded in some other cases with slight modifications. How can I improve it to make it more time efficient?

Read the constraints given in the ques carefully. Range of prime no.s can be of order 10^6 while you have taken the max range of 1000 only in your given code.

I tried using 10^6 …it shows runtime error even in the IDE . Atleast with 1000 , it was working in the IDE but not in the submission. The problem is not that I am getting a wrong answer , its that it is taking too long to get the right answer . I need a more efficient and faster method.

Use sieve of Eratosthenes, its video tutorial is provided in your online course also.