




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















while loop
For loop
Table for 2 2 x 1 = 2 2 x 2 = 4 2 x 3 = 6 : : 2 x 10 = 20
Example - Calculate Table for 2 #include <iostream.h> main ( ) { int counter ; for ( counter = 1 ; counter <= 10 ; counter = counter + 1 ) { }^ }^ cout << "2 x " << counter << " = " << 2 counter << "\n“ ;*
Flow chart for the ‘Table’ example
Print 2*counter
counter <=10?
counter + 1^ Counter =
Example: Calculate Table- Enhanced #include <iostream.h> main ( ) { int number ; int maxMultiplier ; int counter ; maxMultiplier = 10 ; cout << " Please enter the number for which you wish to construct the table “ ; cin >> number ; for ( counter = 1 ; counter <= maxMultiplier ; counter = counter + 1 ) { cout << number <<" x " << counter<< " = " << number * counter << "\n“ ; }^ }
Increment operator ++ counter ++ ; same as counter = counter + 1;
Decrement operator --
counter -- ; same as counter = counter - 1