Computer Science, asked by aratirout12, 10 months ago

briefly discuss IF THEN ENDIF
statement​

Answers

Answered by nupurkandu
0

Explanation:

The most general form of the IF-THEN-ELSE-END IF statement is the following:

IF (logical-expression) THEN

statements-1

ELSE

statements-2

END IF

where statements-1 and statements-2 are sequences of executable statements, and logical-expression is a logical expression. The execution of this IF-THEN-ELSE-END IF statement goes as follows:

the logical-expression is evaluated, yielding a logical value

if the result is .TRUE., the statements in statements-1 are executed

if the result is .FALSE., the statements in statements-2 are executed

after finish executing statements in statements-1 or statements-2, the statement following END IF is executed.

Examples

The following code first reads in an integer into INTEGER variable Number. Then, if Number can be divided evenly by 2 (i.e., Number is a multiple of 2), the WRITE(*,*) between IF and ELSE is executed and shows that the number is even; otherwise, the WRITE(*,*) between ELSE and END IF is executed and shows that the number is odd. Function MOD(x,y) computes the remainder of x divided by y. This is the the remainder (or modulo) function

INTEGER :: Number

Similar questions