4 posts that seem like you have only taken the time to copy and paste your homework questions isn't going to help you learn the material and I can tell you that there aren't many people on here willing to do it all for you.
To get the most out of this forum, take the time to
1)outline the question (yes you have done that)
2)provide your attempt
3)state where you think the problem is or what you don't understand in the code.
until then the best advice I can give you is:
Code:
EDU>> help if
IF Conditionally execute statements.
The general form of the IF statement is
IF expression
statements
ELSEIF expression
statements
ELSE
statements
END
The statements are executed if the real part of the expression
has all non-zero elements. The ELSE and ELSEIF parts are optional.
Zero or more ELSEIF parts can be used as well as nested IF's.
The expression is usually of the form expr rop expr where
rop is ==, <, >, <=, >=, or ~=.
Example
if I == J
A(I,J) = 2;
elseif abs(I-J) == 1
A(I,J) = -1;
else
A(I,J) = 0;
end
See also relop, else, elseif, end, for, while, switch.
Reference page in Help browser
doc if
EDU>> Regards Elbarto