Terry E Snyder Jr
&  
RemoteWebs.com  

Computer & Web Solutions

Support, Design, and more...
| | |
June 23rd, 2017 2:37:06 PM

The for Loop

Syntax

for (variable initializations; conditional value; variable increment)
{
    //code
}

Examples

for(int i=0; i<10; i++)
{
   cout << "i = " << i;

}

int sum;
for(int i=0, sum = 1; i<20; i++, sum += sum + i);
cout << sum << endl;

int sum = 1;
for(int i=0; i<20; i++)
{
   sum += sum + i;
}
cout << sum << endl;

The do while Loop

Syntax

do

{

  //code

} while(conditional value);

Examples

int sum = 1, i = 0;
do
{
	 sum += sum +i;
	 i++;
} while ( i < 20);
cout << sum;
	

The while Loop

Syntax

while(conditional value)

{

  //code

}

Examples

	int sum = 1, i = 0;
	while( i < 20)
	{
		sum += sum + i;
		i++;
	}
	cout << sum;
	

 

Google
 
Web www.terryesnyderjr.com
www.remotewebs.com

Page Updated on October 10, 2012 9:44

www.terryesnyderjr.com Copyright 2000-2017©