Part 1: You need to change the order of your loops to:
for(y = 0; y < h; y++) for(x = 0; x < w; x++)
This will give you a correctly oriented fractal.
Part 2: To get the time to print, you must print it in stderr, since you are printing ppm output to stdout:
fprintf(stderr, "Elapsed time: %.2lf seconds.\n", time_spent);
Part 3: To get a continuous smooth color, you need to use the Normalized Iteration Method method or something similar. Here you can replace your coloring section, which gives you something similar to what you want:
if(i == maxIterations) color(0, 0, 0); // black else { double z = sqrt(newRe * newRe + newIm * newIm); int brightness = 256. * log2(1.75 + i - log2(log2(z))) / log2(double(maxIterations)); color(brightness, brightness, 255); }
This is not entirely true, because I made a simple approximate implementation of the normalized iterative calculation method.

This is not a completely continuous coloration, but it is close.
Justin peel
source share