Print prime number till N

SIR FOLLOWING IS MY CODE - https://ide.codingblocks.com/s/375456


why is this error coming?
when I am putting the input:4000000
output is coming:runguard: warning: timelimit exceeded (wall time): aborting command
runguard: warning: command terminated with signal 15

Hey @aaliyah_beg
Because Its not meeting time constraints of ur code :slight_smile:
i.e why u are getting TLE

sir what is the time limit of any code?

So See Its mentioned with the question what should be the max time limit
Most of the times it will be 1second
In 1second u can do 10^8 operations

Say if u are running a loop for n then its taken as n operations assuming u are not doing simple arithmetic inside

You will learn about Time complexity of code,if u haven’t till now

Sir what do you mean by mentioned with the question , are you trying to say its different for different codes

There are 2 things
Time complexity
&
Time Limit

Time complexity is of code , that’s what u are writing ,u will learn about it in the course.
Say if we have one for loop
for(int i=0;i<n;i++) then its complexity is O(n) i.e it need n operations
Every code has its own time complexity

Time Limit is of question ,accoding to which u decide what should be complexity of ur code .

Here this is a snapshot of some codechef problem , see time limit is mentioned as 1second.
Every question has its own time limit

okay sir, got it. THANK YOU!

1 Like