Tuesday, 28 January 2020

Conditional Instruction & Expressions.

Conditional Instruction 'if' consists of:


1. Conditional expression that evaluates to a boolean value (truth or falsehood).

for example: ( o.getA() > 0 ) might be an expression that evaluates to boolean value.
for example: o.containsData() might be expression that evaluates to boolean value.
for example: ( o != null && o.containsData() && o.getA() > 0 ) might be expression that evaluates to boolean value.


2. Instruction to execute in case of truth.

for example: return; // a valueless return statement.
for example: { } // empty instruction.
for example: doSomething(); // function call.
for example { doSomething(1); doSomething(); } // complex instruction consisting of two function calls,
// with similar function signatures.


3. Syntax.

Syntax is keywords, reserved words, building blocks of a programming language..

syntax can be varied depending on Programming Language, but has to be unambiguous.

for example: if (a = 0) then doSomething();
for example: if (a == 0) { doSomething(); }
for example: if ( (a == 0) iff (b > 3) ) { doSomethingUseful() }


See also: Computer Thinking.

No comments:

Post a Comment