Programming is essentially the manipulation of many variables

Programming is essentially the manipulation of many variables

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Programming is essentially the manipulation of many variables. The basic variable data types which C++ variables can assume are: int (integers), char (characters) and doubles (real decimals). Declaring a variable simply means letting the computer know that you want to reserve a spot in memory for it. Here is an example of declaring a variable: int number_of_items; Defining (or initializing) a variable is giving it a value. Variables can be defined at their declaration: char initial = 'B'; double x_coordinate = 46.72168000517; Of course, variables can be assigned values at a later time, too: int trees, shrubs; trees = 6; shrubs = trees; It is important to note that characters are represented by numbers in the computer, and a
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: char variable can be assigned a numerical value. Characters, Escape Sequences, and Strings Some characters do not have their own symbol and must be referenced by an escape sequence. Some escape sequences are: '\\'-- backslash '\''-- single quotation mark '\"'-- double quotation mark '\b'-- backspace '\n'-- new line '\r'-- carriage return '\t'-- tab A string is a sequence of characters ending in the null character (whose escape sequence is '\0' ). As a beginner, you can usually ignore this definition because strings are usually simply written as constants between double quotes, such as: "florsheim" or "Enter the quantity of shipments:\t"...
View Full Document

Ask a homework question - tutors are online