C conditions, loops, and totals
A for loop has initialization, a condition checked before each iteration, and an update after the body. The remainder operator identifies even integers.
C
#include <stdio.h>
#include <assert.h>
int main(void) {
int total = 0;
for (int i = 1; i <= 6; i++) {
if (i % 2 == 0) total += i;
}
printf("%d\n", total);
assert(total == 12);
return 0;
}