for i<-1 to n do
for j<-1 to n^2 do
write(i*j)
end-for
end-for

call clock() before the loop starts and again after the loop ends, then subtract the two times. When the program runs fast enough the difference might be 0. In that case, put the loops into a function and call that function 1,000 times.

clock_t t1, t2;
t1 = clock();
for(int i = 0; i < 1000; i++)
     RunLoops();
t2 = clock();
clock_t diff = t2 - t1;

call clock() before the loop starts and again after the loop ends, then subtract the two times. When the program runs fast enough the difference might be 0. In that case, put the loops into a function and call that function 1,000 times.

clock_t t1, t2;
t1 = clock();
for(int i = 0; i < 1000; i++)
     RunLoops();
t2 = clock();
clock_t diff = t2 - t1;

my professor just wants us to find the time in terms of the big O by using like T(n) or whatever im just confused on how to find it in those terms. im sorry i should've been more specific

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.