COMP 202 Lecture Notes - Lecture 11: Return Type, Semicolon
![COMP 202 Full Course Notes](https://new-docs-thumbs.oneclass.com/doc_thumbnails/list_view/2177048-class-notes-ca-mcgill-comp-202-lecture10.jpg)
100
COMP 202 Full Course Notes
Verified Note
100 documents
Document Summary
We can condition the execution of blocks of code on the evaluation of boolean expressions. When the condition expression evaluates to true, the following block of code will execute. if (condition) { The expression inside the parentheses of an if must evaluate to a boolean value. if (x < y) { The three prints statements above will only execute if x < y evaluates to true. ** else statements cannot exist by themselves, but if can** If we would like to do something when a condition is true and something else when a condition is false we can use if-else blocks. If the condition evaluates to true, the contents of the if block executes, and the contents of the else block is skipped. If the condition evaluates to false, the contents of the if block is skipped, and the contents of the else block executes.