CS 1371 Lecture 5: 6_conditionals+_1_

70 views5 pages

Document Summary

A conditional statement is a block of code that only runs if a certain condition is met. This is the first time you get to control which of your code is actually run. In the past, all of your code ran from beginning to end. Now, we"ve introduced the concept of control flow so you get to decide which blocks of code run and which are skipped entirely. Conditional statements are useful when you want to separate out different cases. Maybe you only want to calculate how many nice dates you can afford if you have enough money in your bank account to at least cover textbooks for that semester. Perhaps you have an encoder that treats uppercase letters one way and lowercase letters another. If-statements are used when you have a logical condition that is to be evaluated and the code block run only if it"s true. The general form of an if-statement is as follows: if

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