/* To demonstrate for loops. * The sybtax of the for loop is : for(initialization ; condition ; incrememt) * { * loop body * } * initialization is done only once, at the beginning of the loop. * Then, the condition is checked. If it is false, it moves on to the next line after the loop. * If it is true, the loop body is executed and then the increment is executed. * Then the condition is checked once again, and then the whole process is repeated. * * The scope of a variable is the area of code where the vaiable is "alive" * Usually, this is from the line where the variable is declared, until the next } * For a for loop, if a variable is declared in the initialization part of the loop, * it is alive only unitl the end of the loop. */ #include using namespace std; int main() { /*int j=1; //this will bork your computerif it runs long enough while( j<= 100) { cout<=1; i--) { cout<>ans; //The 3 parts of the for loop are optional, but the semi colons are mandatory. //Here, we skip the initialization and increment parts because we aren't counting anything. for( ; ans == 'Y' ; ) { cout<<"No, this is Patrick!!"<>ans; } //Th find and print the factorial of a number long fact = 1; int num; cout<<"Enter a positive integer: "; cin>> num; for(int i=1; i<=num; i++) fact *= i; cout <<"The factorial is "<< fact<