/* * forloop1.c */ #include <stdio.h> int main(void) { int counter; // declare counter int counter2; // declare counter2 int sum = 0; // declare and initialize sum int sum2 = 0; // declare and initialize sum2 printf("%7s\t%3s\t%7s\t%3s\n", "counter", "sum", "counter2", "sum2"); // print right justified headers for( counter=0, counter2=10; counter <=10 ; counter=(counter+1), counter2=(counter2+2) ) // initialize counter to 0 first round // initialize counter2 to 10 // evaluate if counter <=10 // if true, run inside of loop // increment counter by 1 // incremetn counter2 by 2 { sum=(sum+counter); // update the sum, by adding counter to sum. sum2=(sum2+counter); // update the sum2, by adding counter2 to sum2. printf("%4d\t%3d\t%4d\t%3d\n", counter, counter2, sum, sum2); // print right justified counter and sum } return 0; }