Sunday, August 11, 2019
Class Discussion cis 242 Essay Example | Topics and Well Written Essays - 500 words
Class Discussion cis 242 - Essay Example Operators and values are used to define a condition. The operators can be Relational and Logical operators that are used to compare two values; however, Logical operators are also used to combine two or more conditions. An example is given below for illustration of decision making structure using conditions, operators and values: /* ââ¬Å"&&â⬠a logical operator used to compare two conditions, the first condition is either ââ¬Å"aâ⬠is greater than ââ¬Å"10â⬠and the second condition is either ââ¬Å"aâ⬠is less than 20. If both the conditions get true, the ââ¬Å"statements (A)â⬠will be executed and if anyone of the conditions gets false, the ââ¬Å"statements (B)â⬠will be executed. As ââ¬Å"&&â⬠(and) logical operator has been used, therefore, both the conditions need to be true to execute ââ¬Å"statements (A)â⬠. Boolean operators have significance importance in C++, as these can be used in the conditions to determine either the condition is true or false. In programming, you need decision making structures that are based on conditions, whereas in the conditions we use Boolean operators. The above example explains the conditions along with Boolean Operators in detail. Loops are used to add excitement to roller coaster in amusements parks such as Six Flags. :D Just kidding of course, but in C++, they do the same kind of thing: Start at one point, execute some code, then end up back at where you started. They are useful for when you need to execute a piece of code multiple times. The different loop commands have the same basic function, but execute slightly differently. The while command is the simplest of the loops.Just like we say when we talk while (this) is true, do (this). For example: While the TV is on, I will watch it. Once the TV goes off, I will stop watching it. A good use of while is when asking for an entry, check to see that one of the expected entries is the one that the user used. The while loop checks to see if the condition is true before it
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.