for( initialization; condition; increment) { ... Body of loop ... } E.g. for( int i=0; i < 10; i++) { cout << "I is: " << i << endl; }
Exercise: Write a program that computes PI using the first 100 terms of the following sequence:
PI = (4/1) - (4/3) + (4/5) - (4/7) + (4/9) - (4/11) + ...
Use a for loop to implement the above sequence, then use a while loop to implement the above sequence.