C++ examples for Statement:for
Summing integers with the for statement
#include <iostream> int main(int argc, const char *argv[]) { int total = 0; for (int number = 2; number <= 20; number += 2) { total += number;/* w w w .ja v a2s . co m*/ } std::cout << "Sum is " << total << std::endl; return 0; }