Do calculation within the third control expression in for loop

#include <stdio.h> int main(void) { unsigned long long sum = 0LL; // Stores the sum of the integers unsigned int count = 0; // The number of integers to be summed // Read the number of integers to be summed printf("\nEnter the number of integers you want to sum: "); scanf(" %u", &count); // Sum integers from 1 to count for(unsigned int i = 1 ; i <= count ; sum += i++); printf("\nTotal of the first %u numbers is %llu\n", count, sum); return 0;//from w w w . j av a 2 s. c o m }

We 've placed the operation that accumulates the sum in the third control expression for the loop:

for(unsigned int i = 1 ; i<= count ; sum += i++);

The loop statement is empty.

- for Statement
- Draw a box using for loop
- for Loop Control Options
- Use Nested for Loops to draw box
- Use Nested for Loops to sum successive integer sequences
- Nesting for loops