Using a for statement to calculate and print the product of the odd integers from 1 to 15. - C++ Statement

C++ examples for Statement:for

Description

Using a for statement to calculate and print the product of the odd integers from 1 to 15.

Demo Code

#include <iostream>

int main(int argc, const char *argv[]) {
    int product = 1;

    std::cout << "Product of odd integers 1 to 15: ";

    for (int i = 1; i <= 15; i += 2) {
        product *= i;//from w w w  . jav a2s.  com
    }

    std::cout << product << std::endl;

    return 0;
}

Result


Related Tutorials