Task 21: Writing If Statements
Page 1 of 1
Help Center
Task 21: Writing If Statements
eLearning
2 recommended topics
Knowledge Base
Search LearningConnector
Mathcad Prime 2.0 - Programming Mathematical Expressions
Setup
Relevance
Start using Mathcad Prime 2.0 with these free tutorials!
Task 21: Writing If Statements
Write a function reverse that modifies the value of its argument from BLACK to WHITE and vice versa. 1. Create a new function reverse that accepts a variable var.
2. To add an if statement, on the Math tab, in the Operators and Symbols group, click Programming. The programming operators list opens. Click if.
Note You can type the name of a programming operators, such as "if, and then press Ctrl+J to convert the name to a programming operator with all its placeholders. 3. Condition that if the value of var is BLACK, the function returns the value WHITE as shown below. To add the Boolean equal operator for comparison, on the Math tab, in the Operators and Symbols group, click Operators. The operators list opens. Click = Equal To.
4. To add another if statement, position the cursor as shown below and press Enter.
If the cursor is positioned right after WHITE and you press Enter, Mathcad adds a line inside the if block. 5. Specify the opposite case as shown below.
Note Mathcad supports nested if statements. 6. Call reverse and change the value of a variable myvar as shown below.
Keep the file open and proceed to Task 22.
http://127.0.0.1:64851/index.jspx?id=resourceid-131-01BE2B6F&action=show
6/20/2013