Pascal - Conditional statement: if then, if then else
By conditions we can control our program. thanks conditional statement we can control program running in two directions. if the condition is satisfied to continue running the program in a first direction, if not as the second direction. under the directions of the programme I think either statement or block of statements.if then, if then else
Description
if condition then statement1;
if condition then statement1 else statement2;
Input
- condition - Logical value The condition can be any expression
- statement1 - statements
- statement2 - statements
Examples
Pascal
Conditional statement the possible of use:if i > 10 then
begin
i :=10; i := i - 1; inc(i);
end;
if i < 10 then i := 10 else i:=1;
Pascal
Other pieces of example codes:while i>0 do if i=10 then break else begin dec(i); end;
repeat inc(i); if i=3 then break; until (i=10);
if x >= 12 then while y >= 0 do dec(y);
if x = 5 then dec(y);
if x>$abc then y := x / $a;
if i - 10 >0 then i := i-5;
Conditional statement in another programming language:
Differences to: