This preview shows page 1. Sign up to view the full content.
Unformatted text preview: r adding the four ‘input’ assignment statements
save and run your code. Do you get the expected results? Engineering
Education input syntax
General Form: Var = input (' user prompt ' ) ;
R = input ('\nEnter the radius , R: ' ) ;
User prompt The text in purple, except for the \n, will appear in the
command window to prompt the user for input.
The \n is a control sequence that causes the prompt to
be printed on a new line, not required.
An input statement is a special kind of value
assignment statement, don’t forget the semi-colon
How would we tell the user what units to use?
Education Trip Decision
If the goal of this program is to
determine if the trip is feasible with the
We can determine this by comparing
the cost of the trip to the budget.
Since we want to do one thing if
COST<= BUDGET and another if it is
not, we will use an if-else-end
end Notice the quotes around NO and GO in the flowchart Engineering
Education Basic Decision Structures
If one action is needed when a condition is true, and a
different action is needed when the condition if false
statements to execute when true
statements to execute when false
end Relational Operators:
~= condition compares a variable to a value
Y == ‘P’
Statement can be any number of executable
statements including input, fprintf,
View Full Document
- Spring '06