Compiling
Fortunately, you have a computer to keep track of such things. A compiler is a program that takes source files and generates the corresponding streams of machine-level instructions. Consider this function, that calculates two averages and sends them back to the caller through a results struct
:
void calculate_stats(Results * results){ int n = 0, nScanned = 0; double sum_X, sum_Y; sum_X = sum_Y = 0.0; do { double x, y; nScanned = scanf("%lg %lg", &x, &y); if (nScanned == 2) { n++; sum_X += x; sum_Y += y; } } while (nScanned == 2); Results lclResults = { .avg_X = sum_X/n#if CALCULATE_AVG_Y , .avg_Y = sum_Y/n ...
Get Xcode 5 Start to Finish: iOS and OS X Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.