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.
(Find the Smallest Integer) Write a program that uses a for statement to find the smallest of several integers. Assume that the first value read specifies the number of values remaining.
Solution:
 
#include 
 
using namespace std;
 
int main()
{
  int i, smallest;
  cout << "Enter integers (The first value read\nspecifies the number of values remaining):";
  cin >> i;
  cin >> smallest;
 
  for(int b; i > 1; i-- )
  {
  cin >> b;
    if( b < smallest )
      smallest = b;
   }
  cout << "Smallest integer is " << smallest << 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: