// =================================================================== // Program: for_loop_sum.c // Date: July 2020 // Author: Jean-Michel Richer // Email: jean-michel.richer@univ-angers.fr // =================================================================== // Description: // This program shows how to code a for loop in C. // It is intended to be translated in 32 bits x86 assembly // language. // =================================================================== #include #include /** * main function * * we compute the sum of i=1 to 10 = (11*10)/2 = 55 */ int main(int argc, char *argv[]) { int sum = 0; for (int i = 1; i < 11; ++i) { sum += i; } printf("sum=%d\n", sum); return EXIT_SUCCESS; }