This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: // Here we print exactly the same thing, but show that 'className' // means exactly the same thing as '&className[0]'. ±he ampersand is // the "address of" operator. You've seen it in when used with scanf. prinµ("%s secTon %d has %d students enrolled\n", &className[0], i + 1, secTonEnrollment[i]); prinµ("\n"); } // Show the total enrollment in all lab secTons prin±("²otal enrollment: %d\n", getStudentCount(secTonEnrollment, 4)); return 0; } /** * Calculate the total number of students in all lab secTons * * @param enrollments * Array of secTon enrollments * * @param numSecTons * ²he number of secTons (i.e., the number of array elements) * * @return * ²he total number of students enrolled in all lab secTons. */ int getStudentCount(int enrollments, int numSecTons) { int i; int sum; // Begin with no students counted sum = 0; // For each secTon. .. for (i = 0; i < numSecTons; i++) { // . .. add that secTon's enrollment to the sum sum += enrollments[i]; } // Give 'em the fnal sum: the count oF all students in all secTons return sum; }...
View
Full Document
 Spring '15
 DavidAdams
 Articles with example C code

Click to edit the document details