Hey, I'm a complete beginner and I'm trying to understand this program and answer this prompt: "add a line within the for loop to print out the values of i and sum at each iteration."
Can someone please point me in the right direction? Thanks.
#include <stdio.h>
int main(void)
{
int sum = 0; // Stores the sum of the integers
int max = 0; // User -entered max integer to sum to
int i = 1;
printf("Enter the maximum integer to sum until: ");
scanf(" %d", &max);
// Compute sum of integers from 1 to max
for (i = 1; i <= max; i++) {
sum += i;
}
printf("Sum of integers from 1 to %d: %d\n", max, sum);
return 0;
}