Scilab/C2/Conditional-Branching/English-timed

From Script | Spoken-Tutorial
Revision as of 16:11, 9 April 2013 by Sneha (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Time' Narration
00.01 Welcome to the spoken tutorial on Conditional Branching in Scilab.
00.05 To practice this tutorial open the scilab console window on your computer
00.10 We will discuss two types of Conditional constructs in Scilab that is the "if-then-else" construct and the "select-case conditional" construct.
00.19 The if statement allows us to execute a group of statements if a given condition is satisfied.
00.25 Let me give you an example:
00.27 n is equal 42 if n is equal to equal to 42 then disp the number is 42 end of if construct.
00.37 Here 'is equal to' is the assignment operator, which assigns 42 to the variable n, and 'is equal to is equal to' is the equality operator,
00.47 which checks for the equality between the right hand and the left hand side operands.
00.51 In this case n and 42 and gives the result in Boolean.
00.57 Here the comma after the first line is optional, Also the then keyword is optional.
01.04 It can be replaced by a comma or a carriage return.
01.09 The end keyword ends the "if" construct.
01.12 On executing the script, we see the output as follows.
01.20 So far we have seen how to execute a set of statements if a condition is true.
01.27 Now we will see how to execute another set of statements if that condition is false or we may wish to check if some other condition is satisfied.
01.36 We can do this by using 'else' or 'elseif' keyword respectively. Here is how we do it
01.42 In this example, 54 is assigned to a variable n and checked for both true condition using 'if' and false condition using 'else' as described:
01.56 I will cut this paste in the scilab console hit enter
02.03 You see the output.
02.05 If you notice, the examples shown above are on multiple lines.
02.10 They can also be written in a single line with proper semicolons and commas.
02.19 I will cut this and paste in the scilab to execute. hit enter
02.27 The select statement allows to combine several branches in a clear and simple way.
02.32 Depending on the value of a variable, it allows to perform the statement corresponding to the case keyword.
02.38 There can be as many branches as required.
02.41 Let us try with an example.
02.45 We will assign 100 to a variable 'n' and check the cases 42, 54 and a default case represented by else. cut paste hit enter
03.07 Here we see the output .
03.09 This brings us to the end of this spoken tutorial on Conditional Branching using Scilab.
03.15 In this tutorial we have learnt the if - elseif - else statement and the select statement.
03.21 There are many other functions in Scilab which will be covered in other spoken tutorials.
03.25 Keep watching the Scilab links.
03.27 Spoken Tutorials are part of the Talk to a Teacher project, supported by the National Mission on Education through ICT.
03.35 More information on the same is available on the following link http://spoken-tutorial.org/NMEICT-Intro.
03.38 Thanks for joining good bye.

Contributors and Content Editors

Gaurav, Kavita salve, PoojaMoolya, Sandhya.np14, Sneha