Print Friendly and PDF
(Product of Odd Integers) Write a program that uses a for statement to calculate and print the product of the odd integers from 1 to 15.
(Product of Odd Integers) Write a program that uses a for statement to calculate and print

the product of the odd integers from 1 to 15.

Solution:
#include < iostream>
 
using namespace std;
 
int main()
{
  int result = 1;
 
  for( int i = 1; i <= 15; i++ )
  {
     if( i%2 == 1)
       result *= i;
   }
 
  cout << "result is " << result << endl;
 
   //for pause
   system("PAUSE");
   return 0;
}
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: