topical media & game development

talk show tell print

basic-program-code-03-Ex3-13.c

? / basic-program-code-03-Ex3-13.c


  // Ex3_13.cpp
  // Demonstrating nested loops to compute factorials
  include <iostream>
  
  using std::cin;
  using std::cout;
  using std::endl;
  
  int main()
  {
     char indicator = 'n';
     long value = 0,
          factorial = 0;
  
     do
     {
        cout << endl
             << "Enter an integer value: ";
        cin >> value;
  
        factorial = 1;
        for(int i = 2; i <= value; i++)
           factorial *= i;
  
        cout << "Factorial " << value << " is " << factorial;
        cout << endl
             << "Do you want to enter another value (y or n)? ";
        cin >> indicator;
     } while((indicator == 'y') || (indicator == 'Y'));
  
     return 0;
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.