Ampersand

Updated: 07/20/2017 by Computer Hope

AmpersandThe Ampersand ( & ) symbol, also referred to as the "epershand" or "and" symbol, is found above the number 7 key on a US QWERTY keyboard.

Where is the ampersand key on the keyboard?

Below is an overview of a computer keyboard with the ampersand key highlighted in blue.

And key

How to create the & symbol

Creating the & symbol on a U.S. keyboard

To create the ampersand symbol using a U.S. keyboard hold down the Shift key and press the seven key on the top of the keyboard.

Creating the & symbol on a smartphone or tablet

To create an ampersand on a smartphone or tablet open the keyboard and go into the numbers (123) or symbols (sym) section and then press your finger on the & symbol.

What is an ampersand used for on a computer

In literature or English text, the ampersand is used as shorthand to mean "and," as in "John & Rob went to the baseball game." It is also used in programming languages, including Visual Basic (to combine variables and literal text), C++ (denoting an address in memory) and Perl (to call a user-defined subroutine). It can also be used in Excel spreadsheet formulas to combine several values (cells) into a single value (cell) and in HTML for extended HTML characters.

Excel formula example

In the example below, Cell D2 is being made a full name by taking everything in A2, B2, and CD using the ampersand.

Excel formula with an Ampersand

Boolean AND operator

Many programming languages will use two ampersands next to each other as a Boolean AND operator. For example, as seen in the example below if the variables $computer and $hope are equal to one, then a message will be printed indicating that both variables are equal to one.

if (($computer == 1) && ($hope == 1)) {
print "Both variables are equal to one.";
}

HTML extended character example

When creating a web page, some characters (all shown on extended HTML characters page) require an extended character code to be correctly seen. For example, because quotes (") are used in HTML code if you wanted to add a quote to the text of your web pages you would need to use the extended HTML code " within the HTML code. All extended HTML character codes begin with an ampersand and end with a semicolon.

Also, the ampersand itself must also use an extended character code. In other words, if you wanted to show "&" on an HTML web page you would need to use the code & in HTML.

URL example

Within a URL the ampersand is used to separate variables. For example, in the example below there are two different variables, "q" that equals "example search" and "example" that equals "test". These variables can be read by the search.cgi script and used to perform different functions. See our URL definition for further information and a breakdown of URLs.

https://www.computerhope.com/cgi-bin/search.cgi?q=example%20search&example=test

Perl example

In the below Perl example, the subroutine "sayhello" is being called with the &sayhello; command. When this code is executed, it will print "hello" to the screen.

&sayhello;

sub sayhello {
print "hello";
}

Visual Basic example

In the below visual basic example the variable vFullName is being assigned the vFirst and vLast variables to create a variable with the full name.

dim vFirst as string
dim vLast as string
dim vFullName as string

vFirst = "John"
vLast = "Smith"

vFullName = vFirst & " " & vLast

Boolean, Keyboard terms, Operator