C++ Programming Chapters 1-3

¡Supera tus tareas y exámenes ahora con Quizwiz!

Windows and Linux

The two operating systems that the CS computer lab machines boot to.

source file

a human readable file that contains C++ program

assignment statement

allows the programmer to store a value in a variable

more -10 myprog.cpp

linux command for displaying only the first 10 lines of the file

g++

the compiler used in the CS labs for C++

BASIC, FORTRAN, Pascal, Java, C, C++

Examples of high-level languages

cin

a filestream variable that represents the default input source

cout

a filestream variable that represents the default output device

get cin.get(ch);

a function that can be used to read character data, including whitespace; give syntax

variable

a memory location with a name and data type, its content may be changed during program execution

Program Development

a problem solving process

preprocessor

a program that finds and attaches to your program the indicated libraries for compilation

arithmetic expression

a sequence of operands and operators that describe a calculation to be performed

program

a sequence of statements whose objective is to accomplish a task

operating system

a set of programs that control overall computer activity and provide services

programming language

a set of rules, symbols, and special words

data type

a set of values together with a set of operations

algorithm

a step-by-step procedure for solving a problem in a finite amount of time

% modulus

an operator that can only be used with int values. result will always be an int.

allocating memory

associate an identifier with a memory location

CPU and main memory, secondary storage, input and output devices

basic components of computer hardware

case sensitive

both linux and C++ are ___________, meaning that upper case and lower case letters are different

setprecision(n) cout << fixed << showpoint << setprecision(2);

controls output of floating-point numbers; give syntax

floating-point category: float, double

data types that refer to numbers with decimals

a.out

default name of executable file

object file

executable version of program

syntax

grammar rules of the language; compiler will try to identify and locate syntax errors

cmath

header file that contains commonly performed mathematical functions

iomanip

header file that contains commonly used manipulators used to format output

cat

linux command for display file

man

linux command for online manual

cat -n myprog.cpp

linux command that will output the source code and will number the lines of the code.

endl (same as '\n')

manipulator that causes the insertion point (cursor) to move to the beginning of the next line

semantics

meaning of the instructions in the language; compiler cannot find these errors - often called logic errors

.cpp

naming convention for C++ programs

comments

nonexecutable statements that are included in a program to provide information about what the program does, how it works, what input is expected, what output is generated, who wrote it, etc.

unary operator

operator with only one operand

binary operator

operator with two operands

B361

room number of the computer lab

fixed

sets floating-point values to a fixed decimal format

sqrt(x) expects 1 double type expression >= 0.0 as its argument

square root function (give syntax and parameters)

\\

syntax to print backslash (\)

\"

syntax to print double quote

\'

syntax to print single quote

preprocessor directives

tells the computer where to find the library for operations and data types

128 (numbered 0-127)

the number of characters in ASCII

#include <iostream> using namespace std; int main() { return 0; }

the parts required in every C++ program

hardware

the physical components of a computer and its surrounding (peripheral) devices

>>

the stream extraction operator

<<

the stream insertion operator

system software and application software

the two main types of software

static_cast<datatypename>(expression) static_cast<double>(total/divisor) static_cast<char>(65)

type casting syntax

machine language, assembly language, and high-level language

types of programming languages

escape sequences

use 2 characters to represent one '\n' = newline '\t' = tab

manipulator

used to format output

setw(n)

used to output a value in specific # of columns

operand

value, identifier, or expression that is part of the calculation to be performed

type coercion

when a value of one data type is implicitly (automatically) changed to another data type

named constant

a memory location with a name and data type and a value, its content (value) cannot be changed during program execution

compiler

a program that translates instructions written in a high-level language into the equivalent machine code

setfill(ch) cout << setfill('?') << ... ;

allows programmer to fill blank columns in a field with a character

computer

an electronic device capable of performing commands (input, output, storage, arithmetic and logic operations)

like-type expression

an expression in which all operands have the same data type - result will have the same data type as operands

mixed expression

an expression that has operands with different data types

whitespace

characters used to separate symbols, reserved words, identifiers and statements; include blanks, tabs and newline (linefeed) characters

ASCII

collating code commonly used by computers for encoding data into sequences of bits

lpr myfile.cpp

command for printing in the CS lab

emacs

editor used in CS labs

int namespace include using return

examples of reserve words

showpoint

forces the computer to display decimal point and trailing zeroes

high-level language

instructions are closer to natural language, use familiar words and symbols

assembly language

instructions made up of mnemonic codes

machine language

instructions made up of sequences of 0s and 1s

prompt

message displayed to the screen asking user for input; generated with an output statement

identifiers

names of things that are used in a program, can apply to variables, constants, and functions

using namespace std;

place where identifiers used in the system provided header files are defined

pow(x,y) expects 2 double type expressions if x=0.0, y must be positive if x<=0.0, y must be a whole number returns x^y

power function (give syntax and parameters)

#include <headerfilename>

preprocessor directive syntax

programming

process of planning and creating a program

Analysis, Implementation, Maintenance

Three steps of Program Development

editor

program used to create and modify text based files

type casting (conversion)

programmer explicitly indicates that a value is to be converted to another type

high-level language

programming language that: - is machine independent - must be translated by a compiler

machine language

programming language that: - is the only language directly understood and executed by the computer -is machine dependent

assembly language

programming language that: - must be translated to machine language by a program called an assembler - is machine dependent

system software

programs designed to control the computer

application software

programs designed to perform specific tasks

ssh

remote access

software

sets of instructions to be executed by the computer, i.e., programs

char

single letters, digits, special symbols; enclose value in single quotes ('a' '?' '8')

token

smallest individual unit of a programming language - special symbols, word symbols, identifiers

int values

whole numbers, no decimals and no commas included

reserved words

words that are used for special purposes in a program

Arithmetic Operators

* / % + -

special symbols

+ - * / . ; ? , < > <= >= ! != & |

operator

symbol that denotes an action to be performed

const datatype identifier = value;

syntax for named constant declaration

cin >> variable;

syntax for reading char type variables by extracting one nonwhitespace character extracted at a time

cout << left << ...; cout << right << ...;

syntax that allows the programmer to specify whether contents of field will be left or right justified

cout.unsetf(ios::fixed)

syntax to disable the fixed manipulator


Conjuntos de estudio relacionados

Chapter 11 Story of the World, Vol 3

View Set

Art History, Chapter 9; Islamic Art

View Set