CS 18000 Lecture Notes - Lecture 3: Boolean Expression, Substring

45 views2 pages

Document Summary

Return: a statement that returns control or a value to the calling function. Now we use { } for the block forms of if statements: S. i(cid:374)dexof(cid:894)(cid:858)(cid:1005)(cid:859)(cid:895) : fi(cid:374)d the i(cid:374)dex of the (cid:272)hara(cid:272)ter o(cid:374)e fro(cid:373) the stri(cid:374)g that is stored i(cid:374) (cid:448)ariable x. S. substring(1, 0) : start a substring from index 1 and ending i(cid:374) (cid:1004) (cid:271)ut does(cid:374)(cid:859)t i(cid:374)(cid:272)lude the (cid:272)hara(cid:272)ter at (cid:1004) || and && are short-circuited meaning that for example in: (a==b && d==c), if a==b is true then d==c (cid:449)o(cid:374)(cid:859)t (cid:271)e evaluated unless a==b is false. The else clause goes with the most recent if. If (a < b) minval = a; else minval = b; This can be represented with minval = (a < b)? a : b; Switches evaluates an expression and finds the first variable that matches it. If none match and a default item is given, execution begins from there. A switch is ended by break; or return;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents