I was given the following HomeWork assignment,
Write a program to test on your computer how long it takes to do nlogn, n2, n5, 2n, and n! additions
At least on Unix-like systems, time() only gives you 1-second granularity, so it's not useful for timing things that take a very short amount of time (unless you execute them many times in a loop). Take a look at the gettimeofday() function, which gives you the current time with microsecond resolution. Or consider using clock(), which measure CPU time rather than wall-clock time.