Showing posts with label Expressions. Show all posts
Showing posts with label Expressions. Show all posts

More on "Understanding Basic Language "


This is a continuation from: Understanding Basic Language

Mathematical Operators
To carry out arithmetic operations in programming language, mathematical operators are used. Some of these operators are given below:

Operations        Operator
Addition               +
Subtraction           -
Multiplication       x
Division                /
Greater than          >
Lesser than           <
Exponential          ^
Non equal            <>

Expressions

An expression is something the interpreter calculates (or evaluates).
Some examples given below:
A = 24
B = 25
C = A + B (returns 49)

A = 120
B = 12
C = A / B (returns 10)

A = 34
B = 26
C = A - B (returns 8)


A = 200
B = 100
C = (A * 3) + B (returns 700)

A = 3
B = 2
C = A ^ B (returns 9)

 

Evaluate the following:


100 + 50/2 =
100 + 5 – 90 =
82 – (3 x 20 + 4) =
32 – 23 =
40 / 21 + (20 – 2) =

When the Basic Interpreter is loaded into the memory of the computer, the Basic Interface screen will open.


Type your first program:

10 PRINT “Welcome to the World of BASIC”

Press F2 to run the program. You will see the output as follows:

Press any key to return to the main screen.

Some Important Commands- A command tells the Basic Interpreter to perform a certain task.

PRINT: The PRINT command tells the Interpreter to print something on the screen. In the above case the interpreter prints – “Welcome to the World of Basic”.

Try the following examples

PRINT 5 + 10 * 2
25

PRINT “ROSE & LOTUS”
ROSE & LOTUS

PRINT “COMPUTER”
COMPUTER
                   
PRINT 3 ^ 2 * 5
45

PRINT “SACHIN”                                                 
SACHIN

PRINT “Rahul” ; “Dravid”
RahulDravid

PRINT “Rahul” , “Dravid”
Rahul Dravid
If a List of Instructions has to be given, line numbers will have to be used.

Try the following examples:

10 PRINT 100
20 END
RUN
100
OK

10 PRINT 15
20 PRINT 15 + 15
30 END
RUN
15
30
OK

10 PRINT “THE LOST”
20 PRINT “WORLD”
30 END
RUN
THE LOST
WORLD
OK

10 PRINT “ROHIT”
20 END
30 PRINT “RAM”
RUN
ROHIT
OK

END: The last statement of a program is END. END terminates the program. It means that the program is complete and the computer will ignore any line number given after the END statement.



POINTS TO REMEMBER
- PRINT statement displays anything written after it. It may be data or result.
- END statement is used to terminate the program.
- Once program is over, RUN command is given to execute the program.
- When a Computer has to do more than one calculation then it follows BODMAS Rule.

B à Brackets
O à Of
D à Division
M à Multiplication
A à Addition
S à Subtraction

State “True” or “False”
1) PRINT command cannot be given with line numbers.
2) For division we use “ / “ sign.
3) Non-Numeric data is displayed as it is.
4) The computer will ignore any line number given after END statement.
5) Non-Numeric information is written in double quotation marks.

C# - Expressions and Operators

An expression is a sequence of operators and operands that specify some sort of computation. The operators indicate an operation to be applied to one or two operands. For example, the operators + and - indicate adding and subtracting operands.


For example, the operator + and- indicate adding and subtracting one object from another, respectively. Listing 22 is a simple example of operators and operands.

Listing below shows - The relationship between operators and operands

using System;
class Test
{
static void Main()

LEARN MORE>>>>

Terminology of Boolean Expressions

A Boolean expression has the following terms

Literals
A literal is a single Boolean variable or it's complement
Constant
A constant is a value or the quantity which has a fixed (unchanging) value. In real number (conventional) algebra, constants include all integers and fractions. In Boolean Algebra, there are only two possible constants 1 and 0. These two constants are used to describe true and false, YES or NO, etc.
Variable
A variable is a quantity which can change its value by taking on the value of any constant. At any one itme the variable has only one particular value of constant. There are only two values of constants in the Boolean System. Therefore, a variable in Boolean algebra can only be either 0 or 1. Variables are denoted by letters.
Term
A term is a literal or a collection of literals.
Product Term
A product ( logical AND) of several different literals is called the product term. For example :
A.B' is a product term
Sum Term
The Logical OR of Literals is called the sum term. For example:
A+B'+C
is an example of sum term
Sum of Products
It is the sum (logical OR) of product terms. For example 
A.B' +B.C + A.B.C
is the sum of three different erms i.e. A.B', B.C and A.B.C
Product of Sum
It is tthe product (logical AND) of sum terms. For example:
(A+B).(A+B'+C).(A+C)
is the product of three different sum terms i.e. (A+B), (A+B'+C) and (A+C)
Minterm
A minterm is an AND function that includes each variable once in its normal or complemented form. This is also known as the standard sum of products. For example:
If you have two variables, A and B, there are eight possible terms:
A, B, A', B', A'B', A'B, AB' and AB.
Similarly for three variables we have 26 possible terms.
Maxterm
A maxterm is a logical OR function that includes each variable once in its normal or complemented form. This is known as standard product of sums.

Math & Conversion Functions

These functions are used for various algebric and trignometric operations:
1. abs()
The function abc() calculates the absolute vlaue of an integer. The argument to this function is an integer. It has a prototype in the header file math.h
2. fabs()
The function fabs() returns the absolute value of an argument. The argument to this function is a number of type float or double. It has a prototype in the header file math.h LEARN MORE>>

Expressions

An Expression is comprised of one or more operations. The objects of the operation(s) is reffered to as operands. the conditions are represented by operators.
A C++ expression is a combination of operations, constants, and variables.
An expression is any statement which is composed of one or more operands and returns a value. It may be a combination of operators, variables and constants. the expression may be simple or complex.
Rules of formation of expression: LEARN MORE>>

Operators & Expressions in C++

Introduction
An operator is a symbol or letter which makes the compiler perform a specific operation on operands (variables) in a program.
An expression is a combination of operands ( i.e, constants, variables, numbers), and operators that perform a specific operation and parenthesis.
An expression is a sequence of operators that specifies a computation. an expression may result in a numerical value.
For example: x+y is an expression in which the sign + is an operator which specifies the addition operation. LEARN MORE >>