• Assignment Statement

An Assignment statement is a statement that is used to set a value to the variable name in a program .

Assignment statement allows a variable to hold different types of values during its program lifespan. Another way of understanding an assignment statement is, it stores a value in the memory location which is denoted by a variable name.

Assignment Statement Method

The symbol used in an assignment statement is called as an operator . The symbol is ‘=’ .

Note: The Assignment Operator should never be used for Equality purpose which is double equal sign ‘==’.

The Basic Syntax of Assignment Statement in a programming language is :

variable = expression ;

variable = variable name

expression = it could be either a direct value or a math expression/formula or a function call

Few programming languages such as Java, C, C++ require data type to be specified for the variable, so that it is easy to allocate memory space and store those values during program execution.

data_type variable_name = value ;

In the above-given examples, Variable ‘a’ is assigned a value in the same statement as per its defined data type. A data type is only declared for Variable ‘b’. In the 3 rd line of code, Variable ‘a’ is reassigned the value 25. The 4 th line of code assigns the value for Variable ‘b’.

Assignment Statement Forms

This is one of the most common forms of Assignment Statements. Here the Variable name is defined, initialized, and assigned a value in the same statement. This form is generally used when we want to use the Variable quite a few times and we do not want to change its value very frequently.

Tuple Assignment

Generally, we use this form when we want to define and assign values for more than 1 variable at the same time. This saves time and is an easy method. Note that here every individual variable has a different value assigned to it.

(Code In Python)

Sequence Assignment

(Code in Python)

Multiple-target Assignment or Chain Assignment

In this format, a single value is assigned to two or more variables.

Augmented Assignment

In this format, we use the combination of mathematical expressions and values for the Variable. Other augmented Assignment forms are: &=, -=, **=, etc.

Browse more Topics Under Data Types, Variables and Constants

  • Concept of Data types
  • Built-in Data Types
  • Constants in Programing Language 
  • Access Modifier
  • Variables of Built-in-Datatypes
  • Declaration/Initialization of Variables
  • Type Modifier

Few Rules for Assignment Statement

Few Rules to be followed while writing the Assignment Statements are:

  • Variable names must begin with a letter, underscore, non-number character. Each language has its own conventions.
  • The Data type defined and the variable value must match.
  • A variable name once defined can only be used once in the program. You cannot define it again to store other types of value.
  • If you assign a new value to an existing variable, it will overwrite the previous value and assign the new value.

FAQs on Assignment Statement

Q1. Which of the following shows the syntax of an  assignment statement ?

  • variablename = expression ;
  • expression = variable ;
  • datatype = variablename ;
  • expression = datatype variable ;

Answer – Option A.

Q2. What is an expression ?

  • Same as statement
  • List of statements that make up a program
  • Combination of literals, operators, variables, math formulas used to calculate a value
  • Numbers expressed in digits

Answer – Option C.

Q3. What are the two steps that take place when an  assignment statement  is executed?

  • Evaluate the expression, store the value in the variable
  • Reserve memory, fill it with value
  • Evaluate variable, store the result
  • Store the value in the variable, evaluate the expression.

Customize your course in 30 seconds

Which class are you in.

tutor

Data Types, Variables and Constants

  • Variables in Programming Language
  • Concept of Data Types
  • Declaration of Variables
  • Type Modifiers
  • Access Modifiers
  • Constants in Programming Language

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Download the App

Google Play

The Assignment Statement

Format: [Let] <variable name> = <expression>

The assignment statement (also called the "Let statement", but this is a dated term) causes the value of the expression on the right side of the equal sign to be stored in the variable specified on the left side of the equal sign.

As indicated by the general format, the keyword Let is optional.  It is typically not used.  The following two statements have the exact same meaning:

      Let intC = intA + intB

      intC = intA + intB

An expression can be a constant, variable, or any valid combination of constants and/or variables connected with VB operators such as +, -, *, and /.

The assignment statement has the form variable = constant

(i.e., the <expression> is a constant)

If the variable name on the left of the equal sign is a string variable, then the constant must be a string constant enclosed in quotes.  The quotes are not stored.  Examples follow:

Assume that the following variables are declared:

      Dim strCustName As String

      Dim strCustAddr As String

The statement

      strCustName = "BOB SMITH"

would cause the characters BOB SMITH to be stored in the variable strCustName.

      strCustAddr = " 123 MAIN ST ."

would cause the characters 123 MAIN ST. to be stored in the variable strCustAddr.

If the variable name on the left of the equal sign is a numeric variable (Integer, Long, Single, Double, Currency), then the constant must be a valid numeric constant.  Numeric constants must not be enclosed in quotes.  They must consist only of the digits 0 through 9 and can optionally have a leading sign (- or +) and may have one decimal point.  Examples:

      Dim intPageLimit As Integer

      Dim lngBigInt    As Long

      Dim sngHrlyRate  As Single

      Dim dblCreditAmt As Double

The following statements would cause the specified quantities to be stored in these variables:

      intPageLimit = 60

      lngBigInt = 40567

      sngHrlyRate = 12.50

      dblCreditAmt = -1527483.98

If the variable name on the left of the equal sign is a Date variable, then the constant must be a valid date constant enclosed in pound signs (#). Assume that the following variable is declared:

                Dim dtmHireDate As Date

The following statement would cause the internal representation of November 29, 1999 to be stored in the variable dtmHireDate:

                dtmHireDate = #11/29/99#

Note: Whenever we assign a value to a variable name, the previous value stored in that variable is destroyed and replaced with the new value.  This is called a "destructive replacement" or "destructive write".  For example, if the previous value of the variable intI was 2, and then the statement intI = 6 was executed, the new value of intI would be 6 (the 6 would replace the 2).

The assignment statement has the form variable = variable

(i.e., the <expression> is a variable)

The contents of the variable on the right of the equal sign will be copied to the variable on the left of the equal sign, replacing the previous contents of the variable on the left.  The contents of the variable on the right will remain unchanged.

The examples below assume that the following variables have been declared:

      Dim strName1      As String

      Dim strName2      As String

      Dim intI          As Integer

      Dim intJ          As Integer

Contents before assignment statement is executed:

 

 

 

 

Statement is executed

 

 

 

 

 

Contents after assignment statement is executed:

 

           

Contents before assignment statement is executed:

 

 

 

 

Statement is executed

 

 

 

 

 

Contents after assignment statement is executed:

 

 

The assignment statement has the form variable = expression

(i.e., the <expression> is an arithmetic expression)

If an arithmetic expression is on the right of the equal sign, the expression is evaluated and the result of the expression is stored in the variable on the left of the equal sign.

For example, given the two statements:

      intI = 2

      intJ = intI + 4

In the second statement above, VB will determine that the variable intI contains 2, add the constant 4 to it, and store the result (6) in intJ.

Given these two statements:

      intI = 2

      intI = intI + 1

In mathematics, you could never have a statement like the second one above (intI = intI + 1), because in mathematics, the "="  indicates equality.  But in VB, the "=" does not indicate equality; rather, it means "is replaced by" - i.e., the expression on the right (intI + 1) is first evaluated and determined to be the value 3.  The 3 is then stored in the variable on the left (which happens to be intI).

Other assignment statement notes:

No expression on left of equal sign

There can never be an expression on the left of the equal sign.  For example,

            A + B = C + D

is invalid, it means nothing in VB.  By definition, the function of the assignment statement is to store a value in the variable specified on the left of the equal sign.

Assignment statements with mixed data types

In previous versions of BASIC and VB, you could only assign a string constant or another string variable to a string variable, and you could only assign a numeric constant, numeric variable, or numeric expression to a numeric variable.  Violation of this rule resulted in the generation of a Type Mismatch error.  In later versions of VB, this rule has been relaxed – basically, VB will convert one data type to another if it possibly can; if it can't perform a suitable conversion, the "Type Mismatch " error will still occur.  Generally, "mixed-mode" assignment statements should be avoided when possible; they are inefficient and may sometimes produce unexpected results.

Dim strMyString   As String

 

Dim intMyInt      As Integer

 

Dim sngMySingle   As Single

 

 

 

intMyInt = 2

 

strMyString = intMyInt

causes string representation of "2" to be stored

intMyInt = "5"       

 

converts the string "5" to integer representation of 5

intMyInt = "ABC"         

 

Produces a Type Mismatch error – "ABC" can't be converted to a number

sngMySingle = 3.9

 

strMyString = sngMySingle

stores the string "3.9" in strMyString

intMyInt = sngMySingle 

VB rounds 3.9 up and stores 4 in intMyInt

sngMySingle = 3.5

 

intMyInt = sngMySingle

VB rounds 3.5 up and stores 4 in intMyInt

sngMySingle = 4.5

 

intMyInt = sngMySingle

VB rounds 4.5 and stores 4 in intMyInt

Regarding the last statement, if the decimal portion of a Single or Double is exactly .5, VB always rounds to the nearest even number when converting to an Integer or Long. This is sometimes referred to as "bank rounding".

In the "mixed mode" assignment statements shown above, VB would perform the necessary conversions in these cases wherever it could. Such conversions are called implicit conversions .

In VB, you can also use a set of functions that explicitly convert (or "cast") one type of data to another.  The set of functions that enable you to do this all begin with the letter "C": CBool, CByte, CCur, CDate, CDbl, CDec,  CInt, CLng, CSng, CStr, and CVar. There are also two older functions, Val and Str, which enable you to perform conversions as well. These functions will be covered in a later topic.

Assigning Data to Arrays

Given the following definitions:

Dim aintCount(0 To 9)               As Integer

Dim asngSales(1 To 4, 1 To 5)       As Single

Dim asngResults(3, 1 To 12, 2 To 6) As Single

The following would be valid assignment statements:

      aintCount(4) = 36

      asngSales(2, 3) = 12543.22

      asngResults(0, 11, 5) = 4.567

Assigning Data to UDTs

      Public Type EmployeeName

          FirstName As String

          MidInit   As String

          LastName  As String

      End Type

      Public Type EmployeeRecord

          udtEmpName                   As EmployeeName

          dtmHireDate                  As Date

          sngHourlyRate                As Single

          dblQuarterlyEarnings(1 To 4) As Double

      Dim udtEmpRec           As EmployeeRecord

      Dim audtEmpRec(1 To 10) As EmployeeRecord

      udtEmpRec.sngHourlyRate = 28.75

      audtEmpRec(3).dtmHireDate = #1/15/2001#

      udtEmpRec.udtEmpName.MidInit = "B"

      audtEmpRec(4).dblQuarterlyEarnings(3) = 14950.00

Using With/End With

You can use a With/End With block to "factor out" a qualifying reference in a group of statements. For example, the following sets of statements are equivalent:

 

udtEmpRec.udtEmpName.FirstName = "JOHN"

udtEmpRec.udtEmpName.MidInit = "B"

udtEmpRec.udtEmpName.FirstName = "SMITH"

udtEmpRec.dtmHireDate = #1/15/2001#

udtEmpRec.sngHrlyRate = 28.75

udtEmpRec.dblQuarterlyEarnings(1) = 14950.00

udtEmpRec.dblQuarterlyEarnings(2) = 14950.00

udtEmpRec.dblQuarterlyEarnings(3) = 14950.00

udtEmpRec.dblQuarterlyEarnings(4) = 7475.00

 

With udtEmpRec

    .udtEmpName.FirstName = "JOHN"

    .udtEmpName.MidInit = "B"

    .udtEmpName.FirstName = "SMITH"

    .dtmHireDate = #1/15/2001#

    .sngHrlyRate = 28.75

    .dblQuarterlyEarnings(1) = 14950.00

    .dblQuarterlyEarnings(2) = 14950.00

    .dblQuarterlyEarnings(3) = 14950.00

    .dblQuarterlyEarnings(4) = 7475.00

End With

With statement blocks can be nested. The following sets of statements are equivalent:

 

With udtEmpRec

    .udtEmpName.FirstName = "JOHN"

    .udtEmpName.MidInit = "B"

    .udtEmpName.FirstName = "SMITH"

    .dtmHireDate = #1/15/2001#

    .sngHrlyRate = 28.75

    .dblQuarterlyEarnings(1) = 14950.00

    .dblQuarterlyEarnings(2) = 14950.00

    .dblQuarterlyEarnings(3) = 14950.00

    .dblQuarterlyEarnings(4) = 7475.00

End With

 

With udtEmpRec

    With .udtEmpName

        .FirstName = "JOHN"

        .MidInit = "B"

        .FirstName = "SMITH"

    End With

    .dtmHireDate = #1/15/2001#

    .sngHrlyRate = 28.75

    .dblQuarterlyEarnings(1) = 14950.00

    .dblQuarterlyEarnings(2) = 14950.00

    .dblQuarterlyEarnings(3) = 14950.00

    .dblQuarterlyEarnings(4) = 7475.00

End With

the equal sign in an assignment statement

  • Table of Contents
  • Course Home
  • Assignments
  • Peer Instruction (Instructor)
  • Peer Instruction (Student)
  • Change Course
  • Instructor's Page
  • Progress Page
  • Edit Profile
  • Change Password
  • Scratch ActiveCode
  • Scratch Activecode
  • Instructors Guide
  • About Runestone
  • Report A Problem
  • 1.1 Preface
  • 1.2 Why Programming? Why Java?
  • 1.3 Variables and Data Types
  • 1.4 Expressions and Assignment Statements
  • 1.5 Compound Assignment Operators
  • 1.6 Casting and Ranges of Variables
  • 1.7 Java Development Environments (optional)
  • 1.8 Unit 1 Summary
  • 1.9 Unit 1 Mixed Up Code Practice
  • 1.10 Unit 1 Coding Practice
  • 1.11 Multiple Choice Exercises
  • 1.12 Lesson Workspace
  • 1.3. Variables and Data Types" data-toggle="tooltip">
  • 1.5. Compound Assignment Operators' data-toggle="tooltip" >

1.4. Expressions and Assignment Statements ¶

In this lesson, you will learn about assignment statements and expressions that contain math operators and variables.

1.4.1. Assignment Statements ¶

Remember that a variable holds a value that can change or vary. Assignment statements initialize or change the value stored in a variable using the assignment operator = . An assignment statement always has a single variable on the left hand side of the = sign. The value of the expression on the right hand side of the = sign (which can contain math operators and other variables) is copied into the memory location of the variable on the left hand side.

Assignment statement

Figure 1: Assignment Statement (variable = expression) ¶

Instead of saying equals for the = operator in an assignment statement, say “gets” or “is assigned” to remember that the variable on the left hand side gets or is assigned the value on the right. In the figure above, score is assigned the value of 10 times points (which is another variable) plus 5.

The following video by Dr. Colleen Lewis shows how variables can change values in memory using assignment statements.

As we saw in the video, we can set one variable to a copy of the value of another variable like y = x;. This won’t change the value of the variable that you are copying from.

coding exercise

Click on the Show CodeLens button to step through the code and see how the values of the variables change.

The program is supposed to figure out the total money value given the number of dimes, quarters and nickels. There is an error in the calculation of the total. Fix the error to compute the correct amount.

Calculate and print the total pay given the weekly salary and the number of weeks worked. Use string concatenation with the totalPay variable to produce the output Total Pay = $3000 . Don’t hardcode the number 3000 in your print statement.

exercise

Assume you have a package with a given height 3 inches and width 5 inches. If the package is rotated 90 degrees, you should swap the values for the height and width. The code below makes an attempt to swap the values stored in two variables h and w, which represent height and width. Variable h should end up with w’s initial value of 5 and w should get h’s initial value of 3. Unfortunately this code has an error and does not work. Use the CodeLens to step through the code to understand why it fails to swap the values in h and w.

1-4-7: Explain in your own words why the ErrorSwap program code does not swap the values stored in h and w.

Swapping two variables requires a third variable. Before assigning h = w , you need to store the original value of h in the temporary variable. In the mixed up programs below, drag the blocks to the right to put them in the right order.

The following has the correct code that uses a third variable named “temp” to swap the values in h and w.

The code is mixed up and contains one extra block which is not needed in a correct solution. Drag the needed blocks from the left into the correct order on the right, then check your solution. You will be told if any of the blocks are in the wrong order or if you need to remove one or more blocks.

After three incorrect attempts you will be able to use the Help Me button to make the problem easier.

Fix the code below to perform a correct swap of h and w. You need to add a new variable named temp to use for the swap.

1.4.2. Incrementing the value of a variable ¶

If you use a variable to keep score you would probably increment it (add one to the current value) whenever score should go up. You can do this by setting the variable to the current value of the variable plus one (score = score + 1) as shown below. The formula looks a little crazy in math class, but it makes sense in coding because the variable on the left is set to the value of the arithmetic expression on the right. So, the score variable is set to the previous value of score + 1.

Click on the Show CodeLens button to step through the code and see how the score value changes.

1-4-11: What is the value of b after the following code executes?

  • It sets the value for the variable on the left to the value from evaluating the right side. What is 5 * 2?
  • Correct. 5 * 2 is 10.

1-4-12: What are the values of x, y, and z after the following code executes?

  • x = 0, y = 1, z = 2
  • These are the initial values in the variable, but the values are changed.
  • x = 1, y = 2, z = 3
  • x changes to y's initial value, y's value is doubled, and z is set to 3
  • x = 2, y = 2, z = 3
  • Remember that the equal sign doesn't mean that the two sides are equal. It sets the value for the variable on the left to the value from evaluating the right side.
  • x = 1, y = 0, z = 3

1.4.3. Operators ¶

Java uses the standard mathematical operators for addition ( + ), subtraction ( - ), multiplication ( * ), and division ( / ). Arithmetic expressions can be of type int or double. An arithmetic operation that uses two int values will evaluate to an int value. An arithmetic operation that uses at least one double value will evaluate to a double value. (You may have noticed that + was also used to put text together in the input program above – more on this when we talk about strings.)

Java uses the operator == to test if the value on the left is equal to the value on the right and != to test if two items are not equal. Don’t get one equal sign = confused with two equal signs == ! They mean different things in Java. One equal sign is used to assign a value to a variable. Two equal signs are used to test a variable to see if it is a certain value and that returns true or false as you’ll see below. Use == and != only with int values and not doubles because double values are an approximation and 3.3333 will not equal 3.3334 even though they are very close.

Run the code below to see all the operators in action. Do all of those operators do what you expected? What about 2 / 3 ? Isn’t surprising that it prints 0 ? See the note below.

When Java sees you doing integer division (or any operation with integers) it assumes you want an integer result so it throws away anything after the decimal point in the answer, essentially rounding down the answer to a whole number. If you need a double answer, you should make at least one of the values in the expression a double like 2.0.

With division, another thing to watch out for is dividing by 0. An attempt to divide an integer by zero will result in an ArithmeticException error message. Try it in one of the active code windows above.

Operators can be used to create compound expressions with more than one operator. You can either use a literal value which is a fixed value like 2, or variables in them. When compound expressions are evaluated, operator precedence rules are used, so that *, /, and % are done before + and -. However, anything in parentheses is done first. It doesn’t hurt to put in extra parentheses if you are unsure as to what will be done first.

In the example below, try to guess what it will print out and then run it to see if you are right. Remember to consider operator precedence .

1-4-15: Consider the following code segment. Be careful about integer division.

What is printed when the code segment is executed?

  • 0.666666666666667
  • Don't forget that division and multiplication will be done first due to operator precedence.
  • Yes, this is equivalent to (5 + ((a/b)*c) - 1).
  • Don't forget that division and multiplication will be done first due to operator precedence, and that an int/int gives an int result where it is rounded down to the nearest int.

1-4-16: Consider the following code segment.

What is the value of the expression?

  • Dividing an integer by an integer results in an integer
  • Correct. Dividing an integer by an integer results in an integer
  • The value 5.5 will be rounded down to 5

1-4-17: Consider the following code segment.

  • Correct. Dividing a double by an integer results in a double
  • Dividing a double by an integer results in a double

1-4-18: Consider the following code segment.

  • Correct. Dividing an integer by an double results in a double
  • Dividing an integer by an double results in a double

1.4.4. The Modulo Operator ¶

The percent sign operator ( % ) is the mod (modulo) or remainder operator. The mod operator ( x % y ) returns the remainder after you divide x (first number) by y (second number) so 5 % 2 will return 1 since 2 goes into 5 two times with a remainder of 1. Remember long division when you had to specify how many times one number went into another evenly and the remainder? That remainder is what is returned by the modulo operator.

../_images/mod-py.png

Figure 2: Long division showing the whole number result and the remainder ¶

In the example below, try to guess what it will print out and then run it to see if you are right.

The result of x % y when x is smaller than y is always x . The value y can’t go into x at all (goes in 0 times), since x is smaller than y , so the result is just x . So if you see 2 % 3 the result is 2 .

1-4-21: What is the result of 158 % 10?

  • This would be the result of 158 divided by 10. modulo gives you the remainder.
  • modulo gives you the remainder after the division.
  • When you divide 158 by 10 you get a remainder of 8.

1-4-22: What is the result of 3 % 8?

  • 8 goes into 3 no times so the remainder is 3. The remainder of a smaller number divided by a larger number is always the smaller number!
  • This would be the remainder if the question was 8 % 3 but here we are asking for the reminder after we divide 3 by 8.
  • What is the remainder after you divide 3 by 8?

1.4.5. FlowCharting ¶

Assume you have 16 pieces of pizza and 5 people. If everyone gets the same number of slices, how many slices does each person get? Are there any leftover pieces?

In industry, a flowchart is used to describe a process through symbols and text. A flowchart usually does not show variable declarations, but it can show assignment statements (drawn as rectangle) and output statements (drawn as rhomboid).

The flowchart in figure 3 shows a process to compute the fair distribution of pizza slices among a number of people. The process relies on integer division to determine slices per person, and the mod operator to determine remaining slices.

Flow Chart

Figure 3: Example Flow Chart ¶

A flowchart shows pseudo-code, which is like Java but not exactly the same. Syntactic details like semi-colons are omitted, and input and output is described in abstract terms.

Complete the program based on the process shown in the Figure 3 flowchart. Note the first line of code declares all 4 variables as type int. Add assignment statements and print statements to compute and print the slices per person and leftover slices. Use System.out.println for output.

1.4.6. Storing User Input in Variables ¶

Variables are a powerful abstraction in programming because the same algorithm can be used with different input values saved in variables.

Program input and output

Figure 4: Program input and output ¶

A Java program can ask the user to type in one or more values. The Java class Scanner is used to read from the keyboard input stream, which is referenced by System.in . Normally the keyboard input is typed into a console window, but since this is running in a browser you will type in a small textbox window displayed below the code. The code below shows an example of prompting the user to enter a name and then printing a greeting. The code String name = scan.nextLine() gets the string value you enter as program input and then stores the value in a variable.

Run the program a few times, typing in a different name. The code works for any name: behold, the power of variables!

Run this program to read in a name from the input stream. You can type a different name in the input window shown below the code.

Try stepping through the code with the CodeLens tool to see how the name variable is assigned to the value read by the scanner. You will have to click “Hide CodeLens” and then “Show in CodeLens” to enter a different name for input.

The Scanner class has several useful methods for reading user input. A token is a sequence of characters separated by white space.

Method

Description

nextLine()

Scans all input up to the line break as a String

next()

Scans the next token of the input as a String

nextInt()

Scans the next token of the input as an int

nextDouble()

Scans the next token of the input as a double

nextBoolean()

Scans the next token of the input as a boolean

Run this program to read in an integer from the input stream. You can type a different integer value in the input window shown below the code.

A rhomboid (slanted rectangle) is used in a flowchart to depict data flowing into and out of a program. The previous flowchart in Figure 3 used a rhomboid to indicate program output. A rhomboid is also used to denote reading a value from the input stream.

Flow Chart

Figure 5: Flow Chart Reading User Input ¶

Figure 5 contains an updated version of the pizza calculator process. The first two steps have been altered to initialize the pizzaSlices and numPeople variables by reading two values from the input stream. In Java this will be done using a Scanner object and reading from System.in.

Complete the program based on the process shown in the Figure 5 flowchart. The program should scan two integer values to initialize pizzaSlices and numPeople. Run the program a few times to experiment with different values for input. What happens if you enter 0 for the number of people? The program will bomb due to division by zero! We will see how to prevent this in a later lesson.

The program below reads two integer values from the input stream and attempts to print the sum. Unfortunately there is a problem with the last line of code that prints the sum.

Run the program and look at the result. When the input is 5 and 7 , the output is Sum is 57 . Both of the + operators in the print statement are performing string concatenation. While the first + operator should perform string concatenation, the second + operator should perform addition. You can force the second + operator to perform addition by putting the arithmetic expression in parentheses ( num1 + num2 ) .

More information on using the Scanner class can be found here https://www.w3schools.com/java/java_user_input.asp

1.4.7. Programming Challenge : Dog Years ¶

In this programming challenge, you will calculate your age, and your pet’s age from your birthdates, and your pet’s age in dog years. In the code below, type in the current year, the year you were born, the year your dog or cat was born (if you don’t have one, make one up!) in the variables below. Then write formulas in assignment statements to calculate how old you are, how old your dog or cat is, and how old they are in dog years which is 7 times a human year. Finally, print it all out.

Calculate your age and your pet’s age from the birthdates, and then your pet’s age in dog years. If you want an extra challenge, try reading the values using a Scanner.

1.4.8. Summary ¶

Arithmetic expressions include expressions of type int and double.

The arithmetic operators consist of +, -, * , /, and % (modulo for the remainder in division).

An arithmetic operation that uses two int values will evaluate to an int value. With integer division, any decimal part in the result will be thrown away, essentially rounding down the answer to a whole number.

An arithmetic operation that uses at least one double value will evaluate to a double value.

Operators can be used to construct compound expressions.

During evaluation, operands are associated with operators according to operator precedence to determine how they are grouped. (*, /, % have precedence over + and -, unless parentheses are used to group those.)

An attempt to divide an integer by zero will result in an ArithmeticException to occur.

The assignment operator (=) allows a program to initialize or change the value stored in a variable. The value of the expression on the right is stored in the variable on the left.

During execution, expressions are evaluated to produce a single value.

The value of an expression has a type based on the evaluation of the expression.

Lesson 4: Assignment Statements and Numeric Functions

Once you've read your data into a SAS data set, surely you want to do something with it. A common thing to do is to change the original data in some way in an attempt to answer a research question of interest to you. You can change the data in one of two ways:

  • You can use a basic assignment statement in which you add some information to all of the observations in the data set. Some assignment statements may take advantage of the numerous SAS functions that are available to make programming certain calculations easier ( e.g. , taking an average).
  • Alternatively, you can use an if-then-else statement to add some information to some but not all of the observations. In this lesson, we will learn how to use assignment statements and numeric SAS functions to change your data. In the next lesson, we will learn how to use if-then-else statements to change a subset of your data.

Modifying your data may involve not only changing the values of a particular variable but also the type of the variable. That is, you might need to change a character variable to a numeric variable. For that reason, we'll investigate how to use the INPUT function to convert character data values to numeric values. (We'll learn how to use the PUT function to convert numeric values to character values in Stat 481 when we study character functions in depth.)

Upon completing this lesson, you should be able to do the following:

  • write a basic assignment statement involving a numeric variable
  • write an assignment statement that involves an arithmetic calculation
  • write an assignment statement that utilizes one of the many numeric SAS functions that are available
  • describe how SAS handles missing values for various arithmetic calculations and functions
  • write an assignment statement involving nested functions
  • write a basic assignment statement involving a character variable
  • convert character data values to numeric values using the INPUT function

4.1 - Assignment Statement Basics

The fundamental method of modifying the data in a data set is by way of a basic assignment statement. Such a statement always takes the form:

variable = expression;

where the variable is any valid SAS name and the expression is the calculation that is necessary to give the variable its values. The variable must always appear to the left of the equal sign and the expression must always appear to the right of the equal sign. As always, the statement must end with a semicolon (;).

Because assignment statements involve changing the values of variables, in the process of learning about assignment statements we'll get practice with working with both numeric and character variables. We'll also learn how using numeric SAS functions can help to simplify some of our calculations.

Example 4.1

Throughout this lesson, we'll work on modifying various aspects of the temporary data set grades that are created in the following DATA step:

The data set contains student names ( name ), each of their four exam grades ( e1 , e2 , e3 , e4 ), their project grade ( p1 ), and their final exam grade ( f1 ).

A couple of comments. For the sake of the examples that follow, we'll use the DATALINES statement to read in the data. We could have just as easily used the INFILE statement. Additionally, for the sake of ease, we'll create temporary data sets rather than permanent ones. Finally, after each SAS DATA step, we'll use the PRINT procedure to print all or part of the resulting SAS data set for your perusal.

Example 4.2

The following SAS program illustrates a very simple assignment statement in which SAS adds up the four exam scores of each student and stores the result in a new numeric variable called examtotal .

Note that, as previously described, the new variable name examtotal appears to the left of the equal sign, while the expression that adds up the four exam scores ( e1 + e2 + e3 + e4 ) appears to the right of the equal sign.

Launch and run    the SAS program. Review the output from the PRINT procedure to convince yourself that the new numeric variable examtotal is indeed the sum of the four exam scores for each student appearing in the data set. Also, note what SAS does when it is asked to calculate something when some of the data are missing. Rather than add up the three exam scores that do exist for John Simon, SAS instead assigns a missing value to his examtotal . If you think about it, that's a good thing! Otherwise, you'd have no way of knowing that his examtotal differed in some fundamental way from that of the other students. The important lesson here is to always be aware of how SAS is going to handle the missing values in your data set when you perform various calculations!

Example 4.3

In the previous example, the assignment statement created a new variable in the data set by simply using a variable name that didn't already exist in the data set. You need not always use a new variable name. Instead, you could modify the values of a variable that already exists. The following SAS program illustrates how the instructor would modify the variable e2 , say for example, if she wanted to modify the grades of the second exam by adding 8 points to each student's grade:

Note again that the name of the variable being modified ( e2 ) appears to the left of the equal sign, while the arithmetic expression that tells SAS to add 8 to the second exam score ( e2 +8) appears to the right of the equal sign. In general, when a variable name appears on both sides of the equal sign, the original value on the right side is used to evaluate the expression. The result of the expression is then assigned to the variable on the left side of the equal sign.

Launch and run    the SAS program. Review the output from the print procedure to convince yourself that the values of the numeric variable e2 are indeed eight points higher than the values in the original data set.

4.2 - Arithmetic Calculations Using Arithmetic Operators

All we've done so far is add variables together. Of course, we could also subtract, multiply, divide, or exponentiate variables. We just have to make sure that we use the symbols that SAS recognizes. They are:

Operation

Symbol

Assignment Statement

Action Taken

addition

+

= + ;

add and

subtraction

-

= - ;

subtract from

multiplication

*

= * ;

multiply and

division

/

= / ;

divide by

exponentiation

**

= ** ;

raise to the power of

negative prefix

-

= - ;

take the negative of

As is the case in other programming languages, you can perform more than one operation in an assignment statement. The operations are performed as they are for any mathematical expression, namely:

  • exponentiation is performed first, then multiplication and division, and finally addition and subtraction
  • if multiple instances of addition, multiple instances of subtraction, or addition and subtraction appear together in the same expression, the operations are performed from left to right
  • if multiple instances of multiplication, multiple instances of division, or multiplication and division appear together in the same expression, the operations are performed from left to right
  • if multiple instances of exponentiation occur in the same expression, the operations are performed right to left
  • operations in parentheses are performed first

It's that last bullet that I think is the most helpful to know. If you use parentheses to specifically tell SAS what you want to be calculated first, then you needn't worry as much about the other rules. Let's take a look at two examples.

Example 4.4

The following example contains a calculation that illustrates the standard order of operations. Suppose a statistics instructor calculates the final grade by weighting the average exam score by 0.6, the project score by 0.2, and the final exam by 0.2. The following SAS program illustrates how the instructor (incorrectly) calculates the students' final grades:

Well, okay, so the instructor should stick to statistics and not mathematics. As you can see in the assignment statement, the instructor is attempting to tell SAS to average the four exam scores by adding them up and dividing by 4, and then multiplying the result by 0.6. Let's see what SAS does instead. Launch and run    the SAS program, and review the output to see if you can figure out what SAS did, say, for the first student Alexander Smith. If you're still not sure, review the rules for the order of the operations again. The rules tell us that SAS first:

  • takes Alexander's first exam score of 78 and multiples it by 0.6 to get 46.8
  • takes Alexander's fourth exam score of 69 and divides it by 4 to get 17.25
  • takes Alexander's project score of 97 and multiplies it by 0.2 to get 19.4
  • takes Alexander's final exam score of 80 and multiplies it by 0.2 to get 16.0

Then, SAS performs all of the addition:

to get his final score of 267.45. Now, maybe that's the final score that Alexander wants, but it is still fundamentally wrong. Let's see if we can help set the statistics instructor straight by taking advantage of that last rule that says operations in parentheses are performed first.

Example 4.5

The following example contains a calculation that illustrates the standard order of operations. Suppose a statistics instructor calculates the final grade by weighting the average exam score by 0.6, the project score by 0.2, and the final exam by 0.2. The following SAS program illustrates how the instructor (correctly) calculates the students' final grades:

Let's dissect the calculation of Alexander's final score again. The assignment statement for final tells SAS:

  • to first add Alexander's four exam scores (78, 82, 86, 69) to get 315
  • and then divide that total 315 by 4 to get an average exam score of 78.75
  • and then multiply the average exam score of 78.75 by 0.6 to get 47.25
  • and then take Alexander's project score of 97 and multiply it by 0.2 to get 19.4
  • and then take Alexander's final exam score of 80 and multiply it by 0.2 to get 16.0

Then, SAS performs the addition of the last three items:

to get his final score of 82.65. There, that sounds much better. Sorry, Alexander.

Launch and run    the SAS program to see how we did. Review the output from the print procedure to convince yourself that the final grades have been calculated as the instructor wishes. By the way, note again that SAS assigns a missing value to the final grade for John Simon.

In this last example, we calculated the students' average exam scores by adding up their four exam grades and dividing them by 4. We could have instead taken advantage of one of the many numeric functions that are available in SAS, namely that of the MEAN function.

4.3 - Numeric Functions

Just as is the case for other programming languages, such as C++ or S-Plus, a SAS function is a pre-programmed routine that returns a value computed from one or more arguments. The standard form of any SAS function is:

For example, if we want to add three variables, a , b, and c , using the SAS function SUM and assign the resulting value to a variable named d , the correct form of our assignment statement is:

In this case, sum is the name of the function, d is the target variable to which the result of the SUM function is assigned, and a , b , and c are the function's arguments. Some functions require a specific number of arguments, whereas other functions, such as SUM, can contain any number of arguments. Some functions require no arguments. As you'll see in the examples that follow, the arguments can be variable names, constants, or even expressions.

SAS offers arithmetic, financial, statistical, and probability functions. There are far too many of these functions to explore them all in detail, but let's take a look at some examples.

Example 4.6

In the previous example, we calculated students' average exam scores by adding up their four exam grades and dividing by 4. Alternatively, we could use the MEAN function. The following SAS program illustrates the calculation of the average exam scores in two ways — by definition and by using the MEAN function:

Launch and run    the SAS program. Review the output from the PRINT procedure to convince yourself that the two methods of calculating the average exam scores do indeed yield the same results:

The SAS System

Obs

name

e1

e2

e3

e4

avg1

avg2

1

Alexander Smith

78

82

86

69

78.75

78.75

2

John Simon

88

72

86

.

.

82.00

3

Patricia Jones

98

92

92

99

95.25

95.25

4

Jack Benedict

54

63

71

49

59.25

59.25

5

Rene Porter

10

62

88

74

81.00

81.00

Oooops! What happened? SAS reports that the average exam score for John Simon is 82 when the average is calculated using the MEAN function, but reports a missing value when the average is calculated using the definition. If you study the results, you'll soon figure out that when calculating an average using the MEAN function, SAS ignores the missing values and goes ahead and calculates the average based on the available values.

We can't really make some all-conclusive statement about which method is more appropriate, as it really depends on the situation and the intent of the programmer. Instead, the (very) important lesson here is to know how missing values are handled for the various methods that are available in SAS! We can't possibly address all of the possible calculations and functions in this course. So ... you would be wise to always check your calculations out on a few representative observations to make sure that your SAS programming is doing exactly as you intended. This is another one of those good programming practices to jot down.

Although you can refer to SAS Help and Documentation (under " functions , by category ") for a full accounting of the built-in numeric functions that are available in SAS, here is a list of just some of the numeric functions that can be helpful when performing statistical analyses:

 

: the integer portion of a numeric value

: the absolute value of the argument

= ( );

: the square root of the argument

= ( );

: the minimum value of the arguments

= ( , , );

: the maximum value of the arguments

= ( , , );

: the sum of the arguments

= ( , , );

: the mean of the arguments

= ( , , );

: round the argument to the specified unit

= ( , 1);

: the log (base ) of the argument

= ( );

: the value of the argument in the previous observation

= ( );

: the difference between the values of the argument in the current and previous observations

= ( );

: the number of non-missing values of the argument

= ( )

: the number of missing values of the argument

= ( )

I have used the INT function a number of times when dealing with numbers whose first few digits contain some additional information that I need. For example, the area code in this part of Pennsylvania is 814. If I have phone numbers that are stored as numbers, say, as 8142341230, then I can use the INT function to extract the area code from the number. Let's take a look at an example of this use of the INT function.

Example 4.7

The following SAS program uses the INT function to extract the area codes from a set of ten-digit telephone numbers:

In short, the INT function returns the integer part of the expression contained within parentheses. So, if the phone number is 8145562314, then int ( phone /10000000) becomes int (814.5562314) which becomes, as claimed, the area code 814. Now, launch and run    the SAS program, and review the output from the PRINT procedure to convince yourself that the area codes are calculated as claimed.

Example 4.8

One really cool thing is that you can nest functions in SAS (as you can in most programming languages). That is, you can compute a function within another function. When you nest functions, SAS works from the inside out. That is, SAS performs the action in the innermost function first. It uses the result of that function as the argument of the next function, and so on. You can nest any function as long as the function that is used as the argument meets the requirements for the argument.The following SAS program illustrates nested functions when it rounds the students' exam average to the nearest unit:

For example, the average of Alexander's four exams is 78.75 (the sum of 78, 82, 86, and 69 all divided by 4). Thus, in calculating the avg for Alexander, 78.75 becomes the argument for the ROUND function. That is, 78.75 is rounded to the nearest one unit to get 79. Launch and run    the SAS program, and review the output from the PRINT procedure to convince yourself that the exam averages avg are rounded as claimed.

4.4 - Assigning Character Variables

So far, all of our examples have pertained to numeric variables. Now, let's take a look at adding a new character variable to your data set or modifying an existing characteristic variable in your data set. In the previous lessons, we learned how to read the values of a character variable by putting a dollar sign ($) after the variable's name in the INPUT statement. Now, you can update a character variable (or create a new character variable!) by specifying the variable's values in an assignment statement.

Example 4.9

When creating a new character variable in a data set, most often you will want to assign the values based on certain conditions. For example, suppose an instructor wants to create a character variable called status which indicates whether a student "passed" or "failed" based on their overall final grade. A grade below 65, say, might be considered a failing grade, while a grade of 65 or higher might be considered a passing grade. In this case, we would need to make use of an if-then-else statement . We'll learn more about this kind of statement in the next lesson, but you'll get the basic idea here. The following SAS program illustrates the creation of a new character variable called status using an assignment statement in conjunction with an if-then-else statement:

Launch and run    the SAS program. Review the output from the PRINT procedure to convince yourself that the values of the character variable status have been assigned correctly. As you can see, to specify a character variable's value using an assignment statement, you enclose the value in quotes. Some comments:

  • You can use either single quotes or double quotes. Change the single quotes in the above program to double quotes, and re-run    the SAS program to convince yourself that the character values are similarly assigned.
  • If you forget to specify the closing quote, it is typically a show-stopper as SAS continues to scan the program looking for the closing quote. Delete the closing quote in the above program, and re-run    the SAS program to convince yourself that the program fails to accomplish what is intended. Check your log window to see what kind of a warning statement is generated.

4.5 - Converting Data

Suppose you are asked to calculate sales income using the price and the number of units sold. Pretty straightforward, eh? As long as price and units are stored in your data set as numeric variables, then you could just use the assignment statement:

It may be the case, however, that price and units are instead stored as character variables. Then, you can imagine it being a little odd trying to multiply price by units . In that case, the character variables price and units first need to be converted to numeric variables price and units . How SAS helps us do that is the subject of this section. To be specific, we'll learn how the INPUT function converts character values to numeric values.

The reality though is that SAS is a pretty smart application. If you try to do something to a character variable that should only be done to a numeric variable, SAS automatically tries first to convert the character variable to a numeric variable for you. The problem with taking this lazy person's approach is that it doesn't always work the way you'd hoped. That's why, by the end of our discussion, you'll appreciate that the moral of the story is that it is always best for you to perform the conversions yourself using the INPUT function.

Example 4.11

The following SAS program illustrates how SAS tries to perform an automatic character-to-numeric conversion of standtest and e1 , e2 , e3 , and e4 so that arithmetic operations can be performed on them:

Okay, first note that for some crazy reason, all of the data in the data set have been read in as character data. That is, even the exam scores ( e1 , e2 , e3 , e4 ) and the standardized test scores ( standtest ) are stored as character variables. Then, when SAS goes to calculate the average exam score ( avg ), SAS first attempts to convert e1 , e2 , e3 , and e4 to numeric variables. Likewise, when SAS calculates a new standardized test score ( std ), SAS first attempts to convert standtest to a numeric variable. Let's see how it does. Launch and run    the SAS program, and before looking at the output window, take a look at the log window. You should see something that looks like this:

The first NOTE that you see is a standard message that SAS prints in the log to warn you that it performed an automatic character-to-numeric conversion on your behalf. Then, you see three NOTES about invalid numeric data concerning the standtest values 1,210, 1,010, and 1,180. In case you haven't figured it out yourself, it's the commas in those numbers that is throwing SAS for a loop. In general, the automatic conversion produces a numeric missing value from any character value that does not conform to standard numeric values (containing only digits 0, 1, ..., 9, a decimal point, and plus or minus signs). That's why that fifth NOTE is there about missing values being generated. The output itself:

Obs

name

e1

e2

e3

e4

standtest

avg

std

1

Alexander Smith

78

82

86

69

1,210

79

.

2

John Simon

88

72

86

 

990

82

247.50

3

Patricia Jones

98

92

92

99

1,010

95

.

4

Jack Benedict

54

63

71

49

875

59

218.75

5

Rene Porter

100

62

88

74

1,180

81

.

shows the end result of the attempted automatic conversion. The calculation of avg went off without a hitch because e1 , e2 , e3 , and e4 contain standard numeric values, whereas the calculation of std did not because standtest contains nonstandard numeric values. Let's take this character-to-numeric conversion into our own hands.

Example 4.12

The following SAS program illustrates the use of the INPUT function to convert the character variable standtest to a numeric variable explicitly so that an arithmetic operation can be performed on it:

The only difference between the calculation of std here and that in the previous example is that the standtest variable has been inserted here into the INPUT function. The general form of the INPUT function is:

  • source is the character variable, constant or expression to be converted to a numeric variable
  • informat is a numeric informat that allows you to read the values stored in source

In our case, standtest is the character variable we are trying to convert to a numeric variable. The values in standtest conform to the comma5 . informat, and hence its specification in the INPUT function.

Let's see how we did. Launch and run    the SAS program, and again before looking at the output window, take a look at the log window. You should see something that now looks like this:

Ahhaa! No warnings about SAS taking over our program and performing automatic conversions. That's because we are in control this time! Now, looking at the output:

Obs

name

standtest

std

1

Alexander Smith

1,210

302.50

2

John Simon

990

247.50

3

Patricia Jones

1,010

252.50

4

Jack Benedict

875

218.75

5

Rene Porter

1,180

295.00

we see that we successfully calculated std this time around. That's much better!

A couple of closing comments. First, I might use our discussion here to add another item to your growing list of good programming practices. Whenever possible, make sure that you are the one who is in control of your program. That is, know what your program is doing at all times, and if it's not doing what you'd expect it to do for all situations , then rewrite it in such a way to make sure that it does.

Second, you might be wondering "geez, we just spent all this time talking about character-to-numeric conversions, but what happens if I have to do a numeric-to-character conversion instead?" Don't worry ... SAS doesn't let you down. If you try to do something to a character variable that should only be done to a numeric variable, SAS automatically tries first to convert the character variable to a numeric variable. If that doesn't work, then you'll want to use the PUT function to convert your numeric values to character values explicitly. We'll address the PUT function in Stat 481 when we learn about character functions in depth.

4.6 - Summary

In this lesson, we learned how to write basic assignment statements, as well as use numeric SAS functions, in order to change the contents of our SAS data set. One thing you might have noticed is that almost all of our examples involved assignment statements that changed every observation in our data set. There may be situations, however, when you don't want to change every observation, but rather want to change just a subset of observations, those that meet a certain condition. To do so, you have to use if-then-else statements, which we'll learn about in the next lesson. In doing so, we'll also learn a few more good programming practices.

The homework for this lesson will give you practice with assignment statements and numeric functions so that you become even more familiar with how they work and can use them in your own SAS programming.

Variable Assignment

To "assign" a variable means to symbolically associate a specific piece of information with a name. Any operations that are applied to this "name" (or variable) must hold true for any possible values. The assignment operator is the equals sign which SHOULD NEVER be used for equality, which is the double equals sign.

The '=' symbol is the assignment operator. Warning, while the assignment operator looks like the traditional mathematical equals sign, this is NOT the case. The equals operator is '=='

Design Pattern

To evaluate an assignment statement:

  • Evaluate the "right side" of the expression (to the right of the equal sign).
  • Once everything is figured out, place the computed value into the variables bucket.

We've already seen many examples of assignment. Assignment means: "storing a value (of a particular type) under a variable name" . Think of each assignment as copying the value of the righthand side of the expression into a "bucket" associated with the left hand side name!

Read this as, the variable called "name" is "assigned" the value computed by the expression to the right of the assignment operator ('=');

Now that you have seen some variables being assigned, tell me what the following code means?

The answer to above questions: the assignment means that lkjasdlfjlskdfjlksjdflkj is a variable (a really badly named one), but a variable none-the-less. jlkajdsf and lkjsdflkjsdf must also be variables. The sum of the two numbers held in jlkajdsf and lkjsdflkjsdf is stored in the variable lkjasdlfjlskdfjlksjdflkj.

Examples of builtin Data and Variables (and Constants)

For more info, use the "help" command: (e.g., help realmin);

Examples of using Data and Variable

Pattern to memorize, assignment pattern.

The assignment pattern creates a new variable, if this is the first time we have seen the "name", or, updates the variable to a new value!

Read the following code in English as: First, compute the value of the thing to the right of the assignment operator (the =). then store the computed value under the given name, destroying anything that was there before.

Or more concisely: assign the variable "name" the value computed by "right_hand_expression"

Assignment Statements

The last thing we discussed in the previous unit were variables. We use variables to store values of an evaluated expression. To store this value, we use an assignment statement . A simple assignment statement consists of a variable name, an equal sign ( assignment operator ) and the value to be stored.

a in the above expression is assigned the value 7.

Here we see that the variable a has 2 added to it's previous value. The resulting number is 9, the addition of 7 and 2.

To break it down into easy steps:

  • a = 7 -> Variable is initialized when we store a value in it
  • a = a + 2 -> Variable is assigned a new value and forgets the old value

This is called overwriting the variable. a 's value was overwritten in the process. The expression on the right of the = operator is evaluated down to a single value before it is assigned to the variable on the left. During the evaluation stage, a still carries the number 7 , this is added by 2 which results in 9 . 9 is then assigned to the variable a and overwrites the previous value.

Another example:

Hence, when a new value is assigned to a variable, the old one is forgotten.

Variable Names

There are three rules for variable names:

  • It can be only one word, no spaces are allowed.
  • It can use only letters, numbers, and the underscore (_) character.
  • It can’t begin with a number.
Valid variable names Invalid variable names
balance savings-balance (hyphens are not allowed)
savingsBalance savings balance (spaces are not allowed)
savings_balance 2balance (can't begin with a number)
_hello 35 (can't begin with a number)
HELLO hell$$0 (special characters like $ are not allowed)
hello5 'hello' (special characters like ' are not allowed)
Note: Variable names are case-sensitive. This means that hello, Hello, hellO are three different variables. The python convention is to start a variable name with lowercase characters. Tip: A good variable name describes the data it contains. Imagine you have a cat namely Kitty. You could say cat = 'Kitty' .

What would this output: 'name' + 'namename' ? a. 'name' b. 'namenamename' c. 'namename' d. namenamename

What would this output: 'name' * 3 a. 'name' b. 'namenamename' c. 'namename' d. namenamename

results matching " "

No results matching " ".

Java Assignment Operators

Java programming tutorial index.

The Java Assignment Operators are used when you want to assign a value to the expression. The assignment operator denoted by the single equal sign = .

In a Java assignment statement, any expression can be on the right side and the left side must be a variable name. For example, this does not mean that "a" is equal to "b", instead, it means assigning the value of 'b' to 'a'. It is as follows:

Java also has the facility of chain assignment operators, where we can specify a single value for multiple variables.

  • School Guide
  • Mathematics
  • Number System and Arithmetic
  • Trigonometry
  • Probability
  • Mensuration
  • Maths Formulas
  • Integration Formulas
  • Differentiation Formulas
  • Trigonometry Formulas
  • Algebra Formulas
  • Mensuration Formula
  • Statistics Formulas
  • Trigonometric Table

Equal Sign represents ‘equality.’ In mathematics, it’s a symbol that shows when two things are the same. When we want to say two amounts are equal, we use the equal sign to connect them. Equal Sign is crucial in making equations in maths. The equal sign is like a balance and it helps in understanding that the quantities on either side have the same value. Whether in simple arithmetic or more complex algebraic expressions, the equal sign is a fundamental tool in expressing mathematical relationships and maintaining balance in equations. The equal sign is commonly used in both basic math and algebra. Here are some examples to illustrate:

  • 3+2 = 5 (This shows that the sum of 3 and 2 is equal to 5)
  • 8−3 = 5 (Here, it signifies that 8 minus 3 equals 5)
  • 2×4 = 8 (This indicates that 2 multiplied by 4 is equal to 8)
  • 10÷2 = 5 (It states that 10 divided by 2 results in 5)

In each example, the equal sign helps express the equality between the quantities on both sides.

Table of Content

Equal Sign in Maths

Equal to symbol, not equal symbol, other symbols related to equality sign, importance of equal symbol.

Equal sign is written as two horizontal lines, i.e. =. This symbol is used in mathematics to represent two equal values. We know that 2 + 7 is equal to 9 so this is represented as,

Equal Sign is also called, equal to sign, equals sign and other. Equal to sign is located between algebraic expressions and tells us that variables are equal to the what constant and other variables. Every equation in maths has an equal sign and thus the name equation. In keyboards, this symbol is present near the backspace button.

Historical Background of Equal To Sign

The symbol =, representing the equal sign, has its historical origins in the 16th century. Equal Sign was introduced by the mathematician Robert Recorde in 1557, in his work The Whetstone of Witte. Before the equal sign, mathematicians used lengthy phrases to explain equality. Recorde’s innovation offered a concise and clear way to express equality in mathematical notation.

The equal sign’s design is credited to Recorde, who aimed for a balanced and harmonious symbol. With time, it gained broad acceptance and became a standard notation in mathematics.

The equal sign became important in developing algebra and mathematical notation, making it easier to represent equations and improving mathematical communication. Today, it continues to be a key symbol in mathematics, used to show equality and balance in mathematical

The symbol representing the equal sign is ‘=’ with two parallel horizontal lines. It is used specifically when two quantities being compared are precisely the same. Different symbols are employed for various types of comparisons.

Equal-Sign

The unequal sign, denoted as ≠; is a mathematical symbol representing inequality. It signifies that the values on either side of the symbol are not equal. This notation is widely used in mathematics to express comparisons where one quantity is not the same as the other. For example, if you have 5 ≠ 7, it means that 5 is not equal to 7. The symbol helps express the idea that the two numbers are different from each other.

Equal and Not Equal Symbol

The key differences between equal and not equal symbols are listed in the following table:

Aspect Equal ( ) Not Equal ( )
Meaning Represents equality between two values. Represents inequality between two values.
Usage in Programming Used to assign a value to a variable. Used to compare two values for inequality.
Mathematical Notation Indicates equality between two expressions. Indicates inequality between two expressions.
Example (Programming)
Example (Mathematics) = c ≠

Equal Sign has various other symbols which have different meanings and can be used in place of equal sign in mathematics as per the requirement of the statement. Some important symbols related to equality are listed below.

Name of Symbol

Symbol

Meaning

Example

Not Equal To

This symbol is used to state that the values are not equal to each other

5 ≠ 0

Equivalence

Signifies Absolute Equality

Greater than Equal To

Indicates a value equal to or greater than

10 ≥ 8

Less than Equal To

Denotes a value equal to or less than

3 ≤ 5

Approximately Equal To

Represents an approximation

π ≈ 3.14

The equal sign, ‘=’, is crucial in mathematics for several reasons:

  • Expressing Equality: The primary role of the equal sign is to show equality between two quantities. It indicates that the values on either side are the same.
  • Building Equations: The equal sign is fundamental in creating equations and allows us to formulate mathematical relationships and solve problems by representing the balance between different quantities.
  • Algebraic Manipulation: In algebra, the equal sign is instrumental in manipulating expressions and solving equations. enables the transformation of mathematical statements while maintaining equality.
  • Logical Foundation: The equal sign establishes a logical foundation for mathematical operations. It clarifies the relationships between numbers and variables, facilitating a systematic approach to problem-solving.
  • Communication in Mathematics: The equal sign serves as a universal symbol in mathematics, aiding clear and concise communication. It allows mathematicians to convey complex ideas and relationships in a standardized and easily understandable manner.
  • Problem Solving: Whether in basic arithmetic or advanced algebra, the equal sign is essential for solving mathematical problems. It helps in setting up and solving equations to find unknown values.

Equal Sign Examples

Example 1: Find algaberic expression of twice the number plus 12 is equal to 20.

Let the number be “x” According to condition, 2x + 12 = 20

Example 2: 2x + 11 = 5.

2x + 11 = 5 ⇒ 2x = 5 – 11 ⇒ 2x = -6 ⇒ x = -3

Also, Check

  • Greater Than Less Than Symbols
  • Less Than Sign
  • Arithmetic Operations

Practice Problems on Equal Sign

Problem 1: Alex has 15 marbles, and his friend has some marbles. If the number of marbles his friend has is exactly half of Alex’s, how can you express this relationship using the equal sign?

Problem 2: Sarah has 3 times as many apples as Jake. If Jake has A apples, how can you represent the number of apples Sarah has using the equal sign?

Problem 3: The sum of a number p and 12 is equal to 20. How can you write this as a mathematical equation?

Problem 4: Lisa has twice the number of books as Mike. If Mike has B books, how can you use the equal sign to express the number of books Lisa has?

Problem 5: The product of a number q and 5 is 35. How can you represent this relationship using the equal sign?

Equal Sign: FAQs

1. how is the equal sign used in equations.

In equations, the equal sign is used to show that the expressions on either side have the same value. It helps in setting up and solving mathematical problems.

2. Can the Equal Sign be used in real-life scenarios?

Yes, the equal sign is used in various real-life scenarios, especially in fields like science, engineering, and finance, to represent relationships and balance between quantities.

3. What does the equal sign indicate in terms of numbers?

The equal sign indicates that the numbers or expressions on both sides have the same value. It is a fundamental concept in understanding mathematical equality.

4. How does the Equal Sign contribute to Problem-Solving in Mathematics?

The equal sign is essential in problem-solving as it allows the formulation of equations, helping to express relationships between quantities and find solutions to mathematical problems.

5. Are there Common Mistakes associated with the use of the Equal Sign?

Yes, there are common mistakes that include misunderstanding its role, misplacement in equations, and confusion between the equal sign and other symbols.

6. Give an Example of using the Equal Sign in a real-world context?

Certainly, for instance, if the cost of a product is $50 and a discount of $20 is applied, you can use the equal sign to express the final price as $50 – $20 = $30.

7. How does the Equal Sign contribute to clear communication in mathematics?

The equal sign serves as a standardized symbol, making mathematical communication more concise and universally understood. It allows mathematicians to express complex ideas in a straightforward manner.

8. In Computer Programming, how is the Equal Sign utilized?

In computer programming, the equal sign is an assignment operator. It is used to assign a value to a variable. For example, x = 10 assigns the value 10 to the variable x.

9. What is the symbol for the Equal Sign?

The symbol of equal is is two parallel lines which indicates the equality between two things or statements.

10. What is Equal Sign in Physics?

In physics, the equal sign (=) is used to denote mathematical equality, indicating that the expressions on both sides of the sign are equivalent or have the same value.

11. What Symbol is ≅?

≅ is the congruent symbol and is used in mathematics to indicate isomorphic algebraic structures or congruent geometric figures.

12. What Symbol is ≈?

≈ is called the approximately equal to and is used to write approximate values.

author

Please Login to comment...

Similar reads.

  • School Learning
  • Math-Concepts

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

  • Massachusetts Court System

Necklace, Accessories, Jewelry, Accessory, Outdoors

Law Clerk - Probate and Family Court -2025-2026

  • Boston, Massachusetts, United States

TRIAL COURT MISSION 

The Trial Court is committed to: 

  • Fair, impartial, and timely administration of justice;
  • Protection of constitutional and statutory rights and liberties;
  • Equal access to justice for all in a safe and dignified environment strengthened by diversity, equity, and inclusion;
  • Excellence in the adjudication of cases and resolution of disputes;
  • Courteous service to the public by dedicated professionals who inspire public trust and confidence.

The Trial Court is a qualifying employer for Federal Student Loan forgiveness To learn more about this program, and all of our benefits, click here

The Massachusetts Trial Court is an Affirmative Action/Equal Opportunity employer and provides equal opportunity in state employment to all persons. No person shall be denied equal access because of race, creed, color, religion, national origin, ancestry, sex, sexual orientation, gender identity, age, pregnancy, military or veteran status, physical/mental disability; or genetic information. If you need a reasonable accommodation, or have any questions or concerns about being afforded fair and equal treatment, please contact the HR Benefits Team at [email protected]

  • Probate & Family Court Dept
  • Law Clerk/Clerkship
  • Legal/Attorney
  • Closing at: Sep 30 2024 at 23:55 EDT

Title: Law Clerk - Probate & Family Court – 2025-2026

Pay Grade: Grade 16

Starting Pay: $ 73,722.23

Departmental Mission Statement: To deliver timely justice to the public by providing equal access to a fair, equitable and efficient forum to resolve family and probate legal matters and to assist and protect all individuals, families and children in an impartial and respectful manner. Organizational Profile: http://mass.gov/courts/court-info/trial-court/pfc/

This position currently offers a hybrid work schedule.

This clerkship term is from September 2, 2025 - August 31, 2026 This is a posting to serve as a Probate & Family Court Law Clerk in either Eastern or Western Massachusetts.

Eastern Massachusetts may be assigned to Barnstable, Bristol, Essex, Middlesex, Norfolk, Plymouth, Suffolk, and Worcester. Western Massachusetts may be assigned to Berkshire, Hampden, Hampshire, and Franklin. All applicants must upload a resume with the online application. The resume must be in PDF format and its filename must start with the applicant’s last name. Applicants must indicate whether they would like to be considered for a law clerk position in either eastern Massachusetts or western Massachusetts. In addition to the submission of their resume and application online at the Trial Court website, applicants are also required to submit a current transcript (official or unofficial) and a writing sample in response to the fact pattern as listed in this posting.  The transcript and writing sample must be emailed by midnight of September 30, 2024 to: [email protected] .

Letters of recommendation are not requested or required. Applicants selected for interviews may be asked to submit additional materials, including a statement of interest, an official law school transcript, and an additional writing sample.

Position Summary:  The law clerk position is responsible for performing legal research and writing assignments to assist the judges of the Probate and Family Court. The term runs until August 31, 2026. There may be the opportunity to apply for an additional one-year clerkship term. Law clerks work directly with the judges, and under the supervision of the Manager of Legal Research Services, the Managing Attorney, and the Chief Justice. A reliable car and the willingness to travel to courthouses throughout the Commonwealth are requirements of the position. A judicial clerkship in the Massachusetts Probate and Family Court offers a unique, exciting and rewarding environment in which to begin a legal career. The Probate and Family Court hears cases on subjects relating to all aspects of a person’s life, from birth to death. Law clerks in the Probate and Family Court are exposed to a wide variety of family, probate and equity issues; including adoption, paternity, custody, divorce, guardianships, legal bioethics, petitions to partition real estate, trust reformations and will contests. The law in these areas is constantly evolving and cases of first impression often confront the court, making a clerkship experience in the Probate and Family Court interesting and challenging. Cutting edge issues such as the changing definition of family are not uncommon.  Law clerks apply to serve in either eastern or western Massachusetts. The majority of opportunities to serve are in eastern Massachusetts. All law clerks are assigned to rotations by the Manager of Legal Research Services, with the final approval of the Chief Justice. Law clerks based in eastern Massachusetts may be assigned to any of the Probate and Family Court divisions within or east of Worcester County. These are Barnstable, Bristol, Essex, Middlesex, Norfolk, Plymouth, Suffolk, and Worcester. Law clerks based in western Massachusetts may be assigned to any of the Probate and Family Court divisions west of Worcester County. These are Berkshire, Hampden, Hampshire, and Franklin. The rotation system gives law clerks the opportunity to work with numerous judges and to gain a broader understanding of the work of the Probate and Family Court.

  • Attending hearings, portions of trials, and other courtroom proceedings, as needed
  • Discussing legal issues with judges
  • Performing careful and accurate legal research and analysis, using both online and book resources
  • Clearly and concisely conveying results of research and analysis to judges, orally and in writing
  • Preparing well-written and error-free legal research memoranda, and drafting findings of fact, conclusions of law, rationales, judgments and memoranda of decision
  • Completing assignments in a timely manner and within deadlines established by judges
  • Performing additional legal research and analysis and further review and revision of written work products as appropriate
  • Rotating among various Probate and Family Court locations every six months, as assigned by the Administrative Office of the Probate and Family Court
  • Accurately and timely submitting all required administrative forms, such as work logs and case lists, among others
  • Maintaining law clerk offices and work areas, including updating pocket parts of books as necessary
  • Performing related tasks as required

Minimum Requirements: These are the minimum requirements necessary to apply for a position of Law Clerk:

  • Juris Doctor degree from an accredited law school or eligibility to sit for the Massachusetts bar exam, as of the start of the clerkship
  • Excellent legal writing and communication skills
  • Excellent legal research and analytical skills, using both online and book resources
  • High professional and ethical standards
  • Access to a reliable car and the willingness and ability to travel to courthouses as assigned
  • Experience and knowledge in the use of personal computers, including word processing programs such as Microsoft Word and legal research services such as Lexis and Westlaw
  • Demonstrated ability to follow written and oral instructions
  • Demonstrated ability to manage, prioritize, and complete simultaneous assignments from various judges
  • Demonstrated ability to work well independently while maintaining productivity and demonstrating good judgment
  • Demonstrated ability to meet deadlines and otherwise complete assignments in a timely manner
  • Demonstrated ability to work well with others in a professional setting, including judges, managers, court staff, and other law clerks
  • Genuine commitment to serving the full term of the clerkship Additional preferred qualifications include:
  • Membership in the Massachusetts Bar and intent to practice law in Massachusetts
  • Substantial legal research and writing experience, including prior experience as a judicial intern for a Probate and Family Court judge
  • Courses in probate and/or family law, research assistant positions, prior work experience in the areas of probate and family law and clinical placements
  • Familiarity with legal research resources beyond Westlaw and Lexis
  • Demonstrated commitment to government or public service
  • The Probate and Family Court invites well-rounded and distinguished recent law school graduates and practicing attorneys to apply for the clerkship positions. Solid academic credentials are important, however, there are no rigid requirements regarding class rank or standing.
  • All law clerks must reside in Massachusetts for the duration of the law clerk term.

Writing Sample Instructions:  Please draft a response to the fact pattern listed below in the format of a memorandum of law. The writing sample must be typed, double-spaced, and cannot exceed six pages.  Apply Massachusetts statutory and case law to each fact pattern and follow the Blue Book system of citation. The writing sample and the transcript must be emailed by midnight of September 30, 2024 to: [email protected] .

Roger and Mirka were married in April 1999 in Bern, Switzerland. The couple eventually moved to Massachusetts and had six children. The family enjoyed an upper middle-class lifestyle: they funded their children’s participation in tennis, paid for some of their children to attend the Nadal International School, a private high school for talented tennis players, and accumulated personal property of significant value, including Rolex watches, home furnishings, and fine art and antiques. In addition, because of the couple’s generous annual income of over $2 million, and their comparatively modest spending, they also routinely allocated significant portions of their income to investments and savings. Roger and Mirka also consistently donated approximately ten percent of their income to the Swiss Foundation, an early childhood education charity, in which they both are volunteers. Roger is the sole income earner in the family as Mirka stayed home to care for the parties’ six children. In December 2022, Mirka filed a complaint for divorce. The matter came before Judge Williams for trial in May 2024, and the primary contested issues were child support, alimony, and property division. The parties’ five oldest children are emancipated. The parties agree that Mirka should have primary physical custody of the youngest child, Leo, who is fifteen years old.

Judge Williams has come to you seeking advice:

  • Can Judge Williams utilize all of Roger’s $2 million annual income to calculate child support, and decline to order alimony? Judge Williams would like you to provide her with a description of any factors or analysis she will need to consider in deciding whether to order child support, alimony, or both.
  • Assuming Judge Williams decides to order alimony, can she consider the parties’ established practice of saving during the marriage as a component of their marital lifestyle in awarding alimony? Please describe any considerations which will be important to the determination of whether the parties’ practice of saving should be accounted for in the alimony order.  
  • Considering the disparity in the parties’ employability and opportunity to acquire future assets and income, Judge Williams would like to divide the marital estate with Mirka receiving approximately fifty-five percent and Roger receiving approximately forty-five percent. Is this type of equitable, rather than equal, division of the marital estate permissible? What, if any, other factors than those stated should Judge Williams consider in determining how to divide the marital estate?

Share this job with a friend!

Thank you for sharing this job

Other People Viewed

Associate court officer - nantucket district court, associate court officer - edgartown district court, research analyst - department of research and planning/massachusetts sentencing commission, assistant judicial case manager - franklin probate & family court, custodian - greenfield district court, case specialist - worcester district court.

Employment with the Trial Court is contingent upon passage of a criminal record check.

Before you go!

Would you like to sign up for job alerts.

We will email you when new jobs are posted that match your selections.

Massachusetts Trial Court logo

This website uses cookies.

We use cookies to personalise content such as job recommendations, and to analyse our traffic. You consent to our cookies if you click "I Accept". If you click on "I Do Not Accept", then we will not use cookies but you may have a deteriorated user experience. You can change your settings by clicking on the Settings link on the top right of the device

  • Skip to main content
  • Keyboard shortcuts for audio player

Harris tries to flip the script on Trump on the border during raucous Georgia speech

Asma Khalid photographed by Jeff Elkins/Washingtonian

Asma Khalid

Vice President Harris speaks during a campaign rally in Atlanta on July 30, 2024.

Vice President Harris speaks during a campaign rally in Atlanta on July 30, 2024. John Bazemore/AP hide caption

ATLANTA — Vice President Harris used the biggest event of her campaign thus far to take on one of her biggest political liabilities: the reoccurring surges in migration at the southern U.S. border during the Biden administration.

Kamala Harris, then the San Francisco District Attorney, poses for a portrait on June 18, 2004.

Harris is leaning into her history as a prosecutor. It's not the first time

Republicans have attacked Harris as a failed "border czar" who did little to stop migration, even though President Biden had asked her to find ways to address the root causes of migration from Northern Triangle countries early on in her time as vice president. Former President Donald Trump had made border security one of his signature issues, building a wall on the southern border and using various restrictions to try to cut back on immigration.

Sen. Steve Daines, R-Mont., holds up a tweet by Vice President Harris at a news conference at the Capitol on July 30, 2024.

Sen. Steve Daines, R-Mont., holds up a tweet by Vice President Harris at a news conference at the Capitol on July 30, 2024. Kent Nishimura/Getty Images/Getty Images North America hide caption

On Tuesday, Harris tried to turn the tables on this narrative, painting herself as a hard-charging attorney general of a border state who had walked underground tunnels between Mexico and California with law enforcement.

"I went after transnational gangs, drug cartels and human traffickers that came into our country illegally. I prosecuted them in case after case, and I won," Harris said. "Donald Trump, on the other hand, has been talking a big game about securing our border, but he does not walk the walk," she said.

Harris pledged to bring back border security bill

Harris Heads To Guatemala And Mexico As Part Of A 'Buzz Saw' Assignment

Harris Heads To Guatemala And Mexico As Part Of A 'Buzz Saw' Assignment

Harris was only a few months into her time as vice president when Biden gave her a politically treacherous assignment: to find ways to deal with the deep-seated economic and societal problems driving tens of thousands of Central American people to try to seek asylum in the United States.

Her first foreign trip was to Guatemala and Mexico, and Republicans slammed her for not first visiting border communities grappling with increased numbers of people. And then she became irritated in an NBC interview , fueling Republican criticism back home.

Biden and Trump were both at the border today, staking out ground on a key 2024 issue

Biden and Trump were both at the border today, staking out ground on a key 2024 issue

Harris didn't mention her work on the root causes of migration during her Tuesday night speech. Instead, she picked up a strategy that Biden was also seeking to use in his campaign — focusing on a tough border security bill that Biden had agreed to sign, that would give him the authority to, in his words, "shut down the border" when migrant numbers surge.

Republicans in Congress backed away from that bill, after some in the Senate had initially supported it. Harris, like Biden, blamed Trump for tanking the bill, because the issue of immigration played well for him. Biden later took executive action to try to accomplish some of the same goals, though it is being challenged in court.

Vice President Harris speaks at a campaign event at the Georgia State Convocation Center on July 30, 2024 in Atlanta.

Vice President Harris speaks at a campaign event at the Georgia State Convocation Center on July 30, 2024 in Atlanta. Megan Varner/Getty Images hide caption

"Donald Trump does not care about border security — he only cares about himself," Harris said. “As president, I will bring back the border security bill that Donald Trump killed, and I will sign it into law, and show Donald Trump what real leadership looks like," she said.

Harris also addressed inflation concerns

Vice President Harris walks onstage at the 2024 Essence Festival in New Orleans on July 6.

All eyes are on Harris after Biden dropped out and passed her the torch

For the first time in her nascent campaign, Harris also sought to put some details around her economic policy platform, responding to another issue that voters say they are concerned about: the high cost of living.

Harris acknowledged that while many economic indictors show the U.S. economy is strong, people aren't feeling it. "Prices are still too high: you know it and I know it," she said.

She said taking on price gouging would be a "Day One" issue, and talked about banning hidden fees and banks' "surprise late charges." She vowed to "take on corporate landlords" and "cap unfair rent increases," as well as cap prescription drug prices. Harris also mentioned the importance of affordable health care, child care and paid leave policies.

  • Kamala Harris
  • Donald Trump
  • immigration policy
  • border security

IMAGES

  1. LESSON 5

    the equal sign in an assignment statement

  2. Equal Sign: Definition, Symbol and Types with Solved Examples

    the equal sign in an assignment statement

  3. Understanding the Equal Sign

    the equal sign in an assignment statement

  4. Understanding an Equal Sign, Free PDF Download

    the equal sign in an assignment statement

  5. 1st Grade: Understanding The Equal Sign Task Cards {1.OA.7} in 2022

    the equal sign in an assignment statement

  6. PPT

    the equal sign in an assignment statement

VIDEO

  1. FINANCIAL STATEMENT ANALYSIS GROUP ASSIGNMENT

  2. 43 Augmented Assignment statement

  3. Aslvideorecording2024

  4. 6 storing values in variable, assignment statement

  5. Mastering Mesh Analysis: Simplifying Complex Circuit Problems

  6. Sign language video assignment

COMMENTS

  1. 1.4. Expressions and Assignment Statements

    Assignment statements initialize or change the value stored in a variable using the assignment operator =. An assignment statement always has a single variable on the left hand side. The value of the expression ... One equal sign is used to assign a value to a variable. Two equal signs are used to test a variable to see if it is a certain value ...

  2. What are Assignment Statement: Definition, Assignment Statement ...

    The symbol used in an assignment statement is called as an operator. The symbol is '='. Note: The Assignment Operator should never be used for Equality purpose which is double equal sign '=='. The Basic Syntax of Assignment Statement in a programming language is : variable = expression ; where, variable = variable name

  3. The Assignment Statement

    The Assignment Statement. Format: [Let] <variable name> = <expression>. The assignment statement (also called the "Let statement", but this is a dated term) causes the value of the expression on the right side of the equal sign to be stored in the variable specified on the left side of the equal sign. As indicated by the general format, the ...

  4. 4.1

    The variable must always appear to the left of the equal sign and the expression must always appear to the right of the equal sign. As always, the statement must end with a semicolon (;). Because assignment statements involve changing the values of variables, in the process of learning about assignment statements we'll get practice with working ...

  5. 1.4. Expressions and Assignment Statements

    Assignment statements initialize or change the value stored in a variable using the assignment operator =. An assignment statement always has a single variable on the left hand side of the = sign. ... One equal sign is used to assign a value to a variable. Two equal signs are used to test a variable to see if it is a certain value and that ...

  6. 1.7 Java

    An assignment statement designates a value for a variable. An assignment statement can be used as an expression in Java. After a variable is declared, you can assign a value to it by using an assignment statement. In Java, the equal sign = is used as the assignment operator. The syntax for assignment statements is as follows: variable ...

  7. Lesson 4: Assignment Statements and Numeric Functions

    The variable must always appear to the left of the equal sign and the expression must always appear to the right of the equal sign. As always, the statement must end with a semicolon (;). Because assignment statements involve changing the values of variables, in the process of learning about assignment statements we'll get practice with working ...

  8. if statement with equal sign "=" and not "==" in expression

    If MyFunction() returns zero (0) it will call B(); otherwise it will call A().The value of an assignment expression is the value that is assigned to the left hand side; in an if statement 0 is treated as false and all other values as true.. This is perfectly legitimate code, although many compilers will issue a warning.

  9. Programming

    To evaluate an assignment statement: Evaluate the "right side" of the expression (to the right of the equal sign). Once everything is figured out, place the computed value into the variables bucket. More info . We've already seen many examples of assignment. Assignment means: "storing a value (of a particular type) under a variable name".

  10. PDF Resource: Variables, Declarations & Assignment Statements

    That's how assignment works. But in algebra, the equal sign means that the values on both sides are the same. So the way you know computing isn't algebra is that x = x + 1 is meaningless in algebra. No number equals itself plus one. That is a contradiction. So, when you see assignment statements in programming, realize that they mean to ...

  11. Assignment Statements · Pythonium

    To store this value, we use an assignment statement. A simple assignment statement consists of a variable name, an equal sign ( assignment operator) and the value to be stored. a in the above expression is assigned the value 7. Here we see that the variable a has 2 added to it's previous value. The resulting number is 9, the addition of 7 and 2.

  12. Different Forms of Assignment Statements in Python

    The target of an assignment statement is written on the left side of the equal sign (=), and the object on the right can be an arbitrary expression that computes an object. There are some important properties of assignment in Python :-Assignment creates object references instead of copying the objects.

  13. Java Assignment Operators

    Java Assignment Operators. The Java Assignment Operators are used when you want to assign a value to the expression. The assignment operator denoted by the single equal sign =. In a Java assignment statement, any expression can be on the right side and the left side must be a variable name. For example, this does not mean that "a" is equal to ...

  14. 5. SAS Variables and Assignment Statements

    5.1. Assignment Statement Basics. The fundamental method of modifying the data in a data set is by way of a basic assignment statement. Such a statement always takes the form: variable = expression; where variable is any valid SAS name and expression is the calculation that is necessary to give the variable its values.

  15. Visual Basic Chapter 5 (Honors Visual Basic, Ms. Johnson)

    The equal sign in an assignment statement. Assignment Statement. A statement that assigns a value to a destination. Comment. A message entered in the Code Editor window for the purpose of internally documenting the code; begins with an apostrophe. Function.

  16. Equal Sign: Definition, Symbol, Meaning and Examples

    Equal sign is written as two horizontal lines, i.e. =. This symbol is used in mathematics to represent two equal values. We know that 2 + 7 is equal to 9 so this is represented as, 2 + 7 = 9. Equal Sign is also called, equal to sign, equals sign and other. Equal to sign is located between algebraic expressions and tells us that variables are ...

  17. Chapter 2 (C) Flashcards

    the equal sign in an assignment statement. assignment statement. an instruction that assigns a value to something, such as to the property of an object. bugs. the errors in a program. debugging. the process of locating and correcting the bugs (errors) in a program. empty string.

  18. JAVA: CH 5 Flashcards

    JAVA: CH 5. When an expression containing a ____ is part of an if statement, the assignment is illegal. Click the card to flip 👆. Single equal sign. Click the card to flip 👆. 1 / 23.

  19. Answered: In an assignment statement, the equal…

    Assignment #2 Instructions: Through this programming assignment, the students will learn to do the following: Learn to work with command line options and arguments Gain more experience with Makefiles Gain more experience with Unix Learn to use some of the available math funtions available with C Usage: mortgagepmt [-s] -r rate [-d downpayment] price In this assignment, you are asked to perform ...

  20. Law Clerk

    Title: Law Clerk - Probate & Family Court - 2025-2026 Pay Grade: Grade 16 Starting Pay: $ 73,722.23 Departmental Mission Statement: To deliver timely justice to the public by providing equal access to a fair, equitable and efficient forum to resolve family and probate legal matters and to assist and protect all individuals, families and children in an impartial and respectful manner ...

  21. What's the difference between the assignment operator vs equal operator

    An assignment expression has the value of the left operand after the assignment. So y=x in printf( "%d\n", y = x) first lets y take on the value of x, and then evaluates to the (newly assigned) value of y. So the output of the printf-statement will be 5580, i.e. the value of x, which is the new value of y.

  22. The Kamala Harris coconut tree meme, explained as best we can

    "Everything is in context," Harris said, before launching into the now-famous anecdote. "My mother ... would give us a hard time sometimes, and she would say to us, 'I don't know what's wrong ...

  23. Southwest Airlines is getting rid of open seating

    Southwest Airlines is shifting to assigned seats for the first time in its history, a change that will allow the low-fare carrier to charge a premium for some of the seats on its planes.

  24. Harris says she's tougher than Trump on the border : NPR

    Harris was only a few months into her time as vice president when Biden gave her a politically treacherous assignment: to find ways to deal with the deep-seated economic and societal problems ...

  25. The IOC says the Olympic Games has reached gender parity, but ...

    The organization has also reordered the broadcast schedule so that women's events will run during peak viewing times and provided direction to producers to encourage a "gender equal and fair ...

  26. Equal sign/Assignment Operator inside statement

    1. In C and C++ the assignment operator is just an operator like any other. It returns the object on the left side of the assignment. So the parentheses at the end copy order[i] into order[r] and uses then order[r] with its new value. Very important remark: The result of this expression is undetermined: it is not guaranteed that the operands of ...

  27. A GOP congressman called Kamala Harris a 'DEI hire.' Some caution it's

    A strategy that could backfire Continued attacks on Harris' race or gender could ultimately backfire against Republicans, according to Glynda Carr, president of Higher Heights for America, a ...

  28. Harris gets a dream start, but the task ahead is monumental

    The Assignment with Audie Cornish ... who are both expected to soon endorse Harris, put it in a statement, "Vice President Kamala Harris is off to a great start with her promise to pursue the ...