Thursday, December 23, 2010

C ++ Tutorial Loop Structures

#include

using namespace std;

int main () {

cout << "Hello, World! " << endl;

cout << "My For Loop " << endl;

for (int i = 0; i < 6; i++) {
cout << i;
if (i != 5)
cout << ",";
}
cout << endl;


cout << "My While Loop " << endl;

int i = 0;
while ( i < 6) {
cout << i;

if ( i != 5)
cout << ",";
i++;
}
cout << endl;

cout << " My Do-While Loop " << endl;

i = 0;
do {
cout << i;
if ( i != 5)
cout << ",";
i++;
} while ( i < 6);
cout << endl;


return 0;

}

No comments:

Post a Comment