DOC PREVIEW
UCLA COMSCI 31 - CS Lecture 4

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

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

UCLA COMSCI 31 - CS Lecture 4

Download CS Lecture 4
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CS Lecture 4 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CS Lecture 4 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?