Breaking News
You are here: Home / Notes / SEM-1 / CPPM / Evaluation Assignment of Expression

Evaluation Assignment of Expression

EVALUATION OF EXPRESSION – THE LET STATEMENT

 

Any expression framed in BASIC has to be evaluated and stored in memory either as an intermediate result for subsequent use or to be printed out as final result. The function is achieved in BASIC through the LET statement.

The general form of a LET statement which evaluates an expression is.

 

LET (variable) = (expression)

 

Here, “variable” is any valid numeric variable and “expression” is an arithmetic BASIC expression. When a LET statement is encountered, the expression on the right hand side is evaluated. The result then replaces the previous value of the variable on the left hand side.

10      LET X = 10

20      LET A = 5

The LET Statement can have only one variable on the left hand side and only one expression on the right. Statements like

 

10        LET X, Y = W + Z

20        LET A, B =X + Y, X – Y

are not valid.

SELF-REPLACEMENT TECHNIQUE

 

A very important application of the LET statement is to provide increment to a previously defined variable. This is extensively used in counting the number of repetitive operations performed by the computer. it can also be used to generate a new value of a variable based on its previous value. These are known as self-replacement technique of variable.

LET I = I+1

LET X = X*X

 

REFINEMENTS IN PROGRAMMING

The time that computer takes for various operations are as follows.

evaluation of expression

 

RELATIONAL EXPRESSION

In the execution of programs, it is often necessary to compare two numerical quantities (or sometimes string quantities) and take decisions on achieving certain conditions.

Expressions written to compare two quantities using certain relational operators are known as logical or relational expressions. These expressions take only one of the two values, namely, TRUE or FALSE.

The general form of relational expression is:

relational expression

 

For instance, the relational expression

X > Y

will be TRUE if X is greater than Y, otherwise FALSE. This test result is used to change the sequence of execution of statements in a program.

BASIC uses the following relational operators:

relational operator

Download Paper Solutions from Below Link

About admin

Scroll To Top