Nt1310 Unit 6 Assignment

1061 Words3 Pages

An assignment statement is one, which assigns a value to the variable. For example, if we have n = 6; it means the value 6 is assigned to the variable n. Also, the value of the variable may differ depending on the assignment statement. For example, if we have the assignment statement as, n = n – 1; In this case, it gives n the value 5. Syntax: Thus, the general form or the syntax for the assignment statement is given as: variable = expression; Note that the variable has to be declared and expression has to produce a value as the output. Also, if you observe the equal to sign is used as the operator for assignment. To avoid confusions, different programming languages use different operator such as, the assignment operator “: =” is used in …show more content…

Mixed mode Assignment Programming languages allow you to combine Real and Integer variables or constants in a single expression. Such arithmetic expressions are known as mixed mode arithmetic expressions. For example, in the following expressions the iValue1 is allowed as integer as …show more content…

As we can see in the above example, the iValue1 and 1.0 are the two operands and which are not of the same type. One is the integer and the other is a double precision floating point value. Therefore, the above expression is an example of mixed mode expression. A double precision floating point value generally takes 64 bits of memory space and can denote values of dynamic range using floating point. In case of mixed mode expressions, usually the integer is converted into real before performing computations. Hence, mixed mode expression always result in a Real type. Even in case of the above example, the iValue1 get converted to double before computation begins. In most of the iterative computations double works best to maintain the accuracy of results. Rules Following are some of the basic rules to be followed while evaluating mixed mode expressions: 1. Evaluate the expressions always from left to right. The priority of an operator in the expression is determined with respect to the next one in the expression. For example, the following expression must be scanned from left to

More about Nt1310 Unit 6 Assignment

Open Document