Project 1 and Project 2 Due Dates
Deadline: Tuesday 30th May, 4.00pm at DK 4
Project 2 :
Deadline : Tuesday 13th June 2006.,
4.00 pm
These notes are in addition to the text book used in the class of BAA2013 Computer Programming in C++.
Special characters
Character sequence | Result |
\n | Moves cursor to next line (same effect as endl |
\t | Generates a tab character to move the cursor to the next tab stop |
\\ | Prints a backslash (\) |
\’ | Prints a single quotation mark (‘) |
\” | Prints a double quotation mark (“) |
Option | Description |
left | Left justifies the output |
right | Right justifies the output |
showpoint | Displays decimal point and trailing zeros for all floating point numbers, even if the decimal places are not needed |
uppercase | Desplays the “e” in E-notation as “E” rather than “e” |
showpos | Desplays a leading plus sign before positive values |
scientific | Displays floating point numbers in scientific (“E”) notation |
fixed | Displays floating point numbers in normal notation |
PROGRAM DATA
Variables, constants and literals
A variable is the name given to a collection of memory cells, designed to store a particular data item. It is called a variable because the value stored in those memory cells may change or vary as the program executes. For example, the variable total_amount may contain several values during the execution of the program.
A constant is a data item with a name and a value that remain the same during the execution of the program. For example, the name 'fifty' may be given to a data item that contains the value 50.
A literal is a constant whose name is the written representation of its value. For example, the program may contain the literal '50'.
Data Types
At the beginning of a program, the programmer must clearly define the form or type of the data to be collected. The data types can be elementary data items or data structures.
Elementary data items
An elementary data item is one containing a single variable that is always treated as a unit. These data items are usually classified into data types. A data type consists of a set of data values and a set of operations that can be perfiormed on these values. The most common elementary data types are:
Data Structures
A data structure is an aggregate of other data items. The data items that it contains are its components, which may be elementary data items or another data structure. In a data structure, data is grouped together in a particular way, which reflects the situation with which the program is concerned. The most common data structures are:
Files
A popular method of storing information is to enter and store data on a file. The major advantages of using files are:
There are two different methods of storing data on files:
Sequential files may be opened to read or to write, but not both operations on the same file.
Random-access files can be opened to read and write on the same file.