1. which of the following manipulators does not "stick"
                    hex, scientific, setprecision, showbase, setw
  2. give an example of when it would be ok to use a binary file instead 
                  of a text file
  3. give 2 examples where a stringstream can be useful 


len_kim <[EMAIL PROTECTED]> wrote:          Being new to programming and c++, I 
am unable to understand exactly 
what is going on in this example factorial program out of the c++ 
Demystified book. When I input a 3, it returns 6 and I'm not sure how. 
The thing that confuses me is the line that says total *=counter; If 
total = 1, and counter = 3(which is the number I inputted), then total 
*=counter should read as 1 = 1 * 3 which should output a 3. Can someone 
clarify this for me? 

#include <iostream>
using namespace std;
int main()

{ 
int number, counter, total = 1;
cout <<"Enter a number to see the factorial: ";
cin >> number;
cout << "The factorial of " << number << " is ";
for (int counter = 1; counter <= number; counter++)
total *= counter; //how can this return a 6 since total = 1 and counter 
= 3 ??
cout << total;
return 0;
}



         

 
---------------------------------
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.

[Non-text portions of this message have been removed]

Reply via email to