CS 1112 Chapter 1.2: Conditional Statements

46 views2 pages

Document Summary

If statements: if must be followed by a condition that can either be true or false, the conditional can either be a relation between numbers/variables or a boolean. Example of an if statement: if number < 4 area = 5 * number; end. If-else statements are an extension of if statements: if number 4 >= 8 volume = pi * 3; volume = 8; else end. If-elseif-else statements can also be used: if area == 5 fprintf("the are is 5"); elseif area > 5 volume = 17; else end volume = 0; Relational operators are used to create true or false conditions: > indicates greater than: < indicates less than, >= indicates greater than or equal to, <= indicates less than or equal to, == indicates equal to, == indicates equal to, ~= indicates not equal to. Boolean create true or false statements: && is used to signify and

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents