do statementwhile (condition);It does the statement at least once before checking conditions.int k = 0do {cout << “Hello” << end1;k++;} while (k<3);{ cout <<”BLABLABLA”;}-------------------------------------------------------------------------------------------------------------------------for (initialization; stay-in-loop condition;prepare-for-next-iteration)statementeg/for (int k = 0; k < nTimes; k++)do statement 1st, then modification.for (int m = 0; m <10; m++)cout << m*m << end1;cout << “m is now “ << m <<end1;!!!! WONT COMPILE!!!!!! m is initialized in the for loop and can only be used in loopint m;for (m = 0); m <10; m++)cout << m*m << end1;cout << “m is now “ << m <<end1;answer: m is now 10.int m = 0for (; m <10; m++)cout << m*m << end1;cout << “m is now “ << m <<end1;Arraysstring s = “Hello”;for (int k =0; k!= 5 ; k++)cout << s[k]<< end1;if k = 5, undefined behaviour cuz s[5] not available.string blah = “Goodbye”;cout << blah.size(); // writes 7string blah = “The end!”;cout << blah.size(); // writes 8gleep = “LIVE”;for (int k = gleep.size(); k >= 0; k--)cout << gleep[k];cout <<
View Full Document