Question-W2

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Associativity?

(or fixity) of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses; i.e. in what order each operator is evaluated.

Software Components?

- 2 main parts: operating systems/ compiler and interpreters. - Other items: word processors, spreadsheets, database products, web browsers,etc.

Variables and Arithmetic: some fundamentals?

- A bit lenthy

Null character?

- A byte whose value is zero irrespective of any shift state. - it indicates the end of string and many library function rely on it.

Overview of Computer Systems: Major Hardware and Software Components?

- A computer is a machine capable of executing a basic set of instructions called the instruction set. - hardware and software components.

Multibyte characters Vs. Wide characters?

- A multibyte character is a character composed of sequences of one or more bytes. - Each byte sequence represents a single character in the extended character set. - Multibyte characters are used in character sets such as Kanji. - Wide characters are multilingual character codes that are always 16 bits wide. The type for character constants is char; for wide characters, the type is wchar_t. Since wide characters are always a fixed size, using wide characters simplifies programming with international character sets. - The wide-character-string literal L"hello" becomes an array of six integers of type wchar_t.

Assignment Statement?

- A simple executable statement

Algorithms and Programs?

- Algorithm is a way to perform written calculations as opposed to using physical devices. - Algorithm has two properties: 1. termination: algorithm must terminate after a finite number of steps. 2. clarity: each step in algorithm must be unambiguous. -Programs are written in a specific programming language. Think of an algorithm as an abstract concept and a program as its concrete realization.

Summary of real arithmetic?

- Arithmetic with any two real types is done at the highest precision of members involved. - Assignment involved loss of precision if the receiving type has a lower precision than the value being assigned to it. - Further conversions are often implied when expressions mix other types but they have not been described yet.

The alphabet of C?

- Basic alphabet, trigraphs, multibyte characters.

keywords?

- C has a set of keywords for its own use.

Declaration of variables?

- Declaration: declare the name of things before you can use them but it doesn't allocate space until it uses a definition.

Expressions and arithmetic?

- Expressions are build by operands and operators. - Most C's unusual rich set of operators are binary operators (2 operands) or unary operators(1 operand)

External identifier?

- External name - the ones that have to be visible outside the current source code. Ex: library functions or routines which have to be called from several different source files.

Components of Computer Programs?

- Identifiers(analogous to noun) - Statements(sentences) - Function or class declarations(paragraphs) - Comment(footnotes)

Keywords and identifiers?

- Language elements whose forms are identical.

Overview?

- Module 2: Algorithm, basic data types, and expressions. - hardware, software, program, pseudocode. - Declaration of int, float, char, and bool variables. - Assignment statement.s - Input/output statement.

Operators?

- Multiplicative, bitwise, assignment, Increment and decrement.

Precedence and grouping?

- Precedence: The order of precedence is a double redundancy. It refers to which of the mathematical operators has priority over the others. For example 10 + 20 * 30 is calculated as 10 + (20 * 30) and not as (10 + 20) * 30.

the textual structure of programs?

- Program layout, comment, and translation phases.

Statements?

- Statement is like a sentence where expression is like a phrase. - two major types of statements: non-executable statements (no code that performs action) and executable statements(have code that performs action) .

Summary of integral types?

- The integral types are the short, long, signed, unsigned and plain ints. - The commonest is the ordinary int, which is signed unless declared not to be. - The char variables can be made signed or unsigned, as you prefer, but in the absence of indications to the contrary, they will be allocated the most efficient type.

Casts?

- This happens when an expression turns out not to have the type that you wanted it to have and you would like to force it to have a different type. - Putting a type name in parentheses to create a unary operator known as a cast. Ex: (int)

Multibyte characters?

- Two general ways of extending character sets: use fixed number of bytes(often two) for every character or use a shift-in shift-out coding scheme(8 bit communication links).

Coding Errors?

- also called bugs. - 2 categories compile-time errors and run-time errors

Logical Operators?

- are used with variables of the Boolean type. Each operand must be either a Boolean variable itself, or an expression that evaluates to a Boolean answer. - negation operator, AND operator, OR operator, and Precedences and Associativities in Logical Operators.

30. Relative Size Operators?

- are usually used with numeric quantities and correspond to the familiar mathematical inequalities. operator operation example - > greater than x > y - >= greater than or equal to x >= y - < less than x < y - <= less than or equal to x<= y

Comments?

- attempts to explain some piece of code to a person reading the code but it is ignored by the compiler itself. You can specify comments in either of the following ways. - Comments are usually placed on the same line as the code or just before a line of code. A block comment is usually placed at the head of a program, giving a broad overview of the program itself. 1. Type in short comments after two slashes (//). Such comments cannot extend past the end of the line. For example: int number_children ; // number of children in the family 2. Longer comments, which span a single line or multiple lines, may be placed between a starting /* and an ending */. There are no spaces between the / and the * and between the * and the /. For example: /* compute the circumference of the circle */ or /* The following loop counts the number of non-zero elements in the array

Relational Operators ?

- can generally be used to compare any two quantities that are of the same type (i.e., they can be used between two integers, two chars, and so on), and they always produce a Boolean result. - six relational operators—equality, inequality, and four relative size operators.

More complicated types?

- different between signed and unsigned: signed(can be -), unsigned(+ only)

Program layout?

- free format that can be used to lay program out in a way that enhance readability and logical structure. - Space character( spacebar or space).

AND Operator?

- is a binary operator and is denoted by the && symbol. x y x && y false false false false true false true false false true true true

Trigraphs?

- is a technique for the system that can't provide the full 96 characters needed by C, using ISO 646 characters to represent the missing few. - are sequence of three ISO 646 characters that get treated as if they were one character in the C alphabet and it can be seen in source code.

Negation Operator?

- is a unary operator. ex: Thus, if x is true, !x is false, and vice versa.

Equality Operator?

- is denoted by two = signs, with no spaces between them. - Ex: operator example == x == y - For example, if x and y are both int variables, and both happen to contain the number 5, then (x == y) would evaluate to true.

Float type?

- is intended to be small fast representation corresponding to what FORTRAN would call real. - single precision floating point type. Matches IEEE-754 32 bit floating point type if supported.

Translation phases?

- is to proceed as if the phases occurred in this order: 1. Trigraph translation:translating from the source files (parsing trigraphs) to the basic source character set that does not include trigraphs. 2. Line joining 3. Translate comment to space 4. Translate the program

Booleans?

- is used to represent quantities that can take only the values true or false. Ex: "yes/no" questions, for example, "Were you ever married?" - Some languages (e.g., C) do not treat the Boolean type as a separate type. True and false are often represented by the integers 1 and 0. Java and C++ do (rightly) treat Boolean as a separate type. - true and false are keywords in languages that have a built-in Boolean type. - Boolean values are usually represented using one byte.

Plain integers?

- it is the base of integer variables. - signed and unsigned int

run-time errors?

- occur during execution, after compilation or interpretation. The results of a run-time error can be an incorrect or invalid output. - A common one is incorrect or incomplete program design. Another is the use of un-initialized variables. If a variable is not initialized, it can contain invalid or erroneous data.

Conversions?

- occur when there are mixed expressions. - Various types of conversions: integral promotions, between integral types, between floating types, and between floating and integral types.

2. Hardware Components?

- physical components that make up a computer system - Bit(smallest unit of storage) - 8 bits=1 byte - External components(port and bays), Internal components (memories) and peripherals.

Printing real numbers?

- printf - Format for each real type: float(%f), double(%f), long double(%lf).

Unsigned integers?

- range between 0-65535. - unsigned int - is used to be get extra bit of precision and the concept of being negative doesn't exist in the data.

Characters?

- short as char, characters are used to store information that is nonnumeric. Ex: a person's middle initial ('S'), or a person's gender ('M' or 'F'). - Single quotes are used to represent characters ('A'). - char '1' is different from int 1 because they have different internal representations!

Floating and integral conversion?

- simple throw away any fractional part. if integral type can't hold the value that is left, then the behavior is undefined, this is sort of overflow.

Basic alphabet?

- standard 2 character sets: the one that programs written in and the one that programs execute with. - the standard requires an alphabet of 96 symbols for C.

Printing the integral types?

- the behavior of printf is undefined if the wrong format is given.

Character variables?

- the char types: another sort of int with a different application. - signed and unsigned char - range -128 to 127

Identifiers?

- the fancy term used to mean "name" for variables and functions. - Rule: use the 52 upper and lower case alphabetic characters, the 10 digits and the underscore; must start with an alphabet character.

Inequality Operator?

- the not operator (!) is followed by the =, so that this operator literally stands for "not equals," and the pair of symbols forms a single operator. - Ex: operator example != x != y (5 != -3) evaluates to true.

Side effects?

- the problem can be caused by using an assignment, use of the increment operators, calling a function that changes the value of external variable that is also used in the expression.

Floating Point Numbers?

- use to store info with fractional part. Ex: miles per gallon - numbers have a much greater range than ints. - may not be able to precisely represent some numbers (for example, the finite decimal representation of 1/3). - represented internally by a code that contains two parts, the mantissa and the exponent.

Integers?

- used to store information with the whole number (days of week, number of children); no fractional value. - Can be +,-, and 0. - The representation of an integer is precise—the integer is represented exactly by the code.

Real types or real floating point value?

- variety of real types(3): float, double and long double. - each type represents real number in the target computer.

Signed and unsigned integers conversion?

- when convert from singed into unsigned, if singed is non-negative, the value is unchanged. - If the value is(-), convert it by adding to one greater than the maximum that can be held in the unsigned type.

Numeric Types?

-Integer and floating point.

singed integers?

-range between -32,768 to 32,767

How the Assignment Statement Works?

1. First, evaluate the expression that appears on the right side of the =, using the current values of any variables. 2. Then store the value resulting from the evaluation in the variable whose name appears on the left side. The left-hand side must clearly be a valid variable (i.e., memory location).

The usual arithmetic conversions?

1. If either operand is of type long double, the other operand is converted to type long double. 2. If the above condition is not met and either operand is of type double, the other operand is converted to type double. 3. If the above two conditions are not met and either operand is of type float, the other operand is converted to type float. 4. If the above three conditions are not met (none of the operands are of floating types), then integral conversions are performed on the operands as follows: - If either operand is of type unsigned long, the other operand is converted to type unsigned long. - If the above condition is not met and either operand is of type long and the other of type unsigned int, both operands are converted to type unsigned long. - If the above two conditions are not met, and either operand is of type long, the other operand is converted to type long. - If the above three conditions are not met, and either operand is of type unsigned int, the other operand is converted to type unsigned int. - If none of the above conditions are met, both operands are converted to type int.

Basic Data Types?

1. Unstructured: no internal structure (Numeric and non-numeric) 2. structured (arrays, structures, classes and files)

Integral types?

5 types: short, long, signed, unsigned, and plain ints.

Identifiers?

A name given to various piece of program, including including variables, constants, functions, and even statements. - Must begin with a letter of the alphabet - Uppercase and lowercase letters are considered distinct. - Identifiers can be quite long but some practical limitations may exist. -Certain identifiers are reserved for special purposes and carry a special meaning.

Overflow errors?

An error that occurs when the computer attempts to handle a number that is too large for it.

Nonnumeric Types?

Characters and booleans

Compile-time error?

Common causes of compile-time errors include - misspelled words - using identifiers without declaring them - misplaced semicolons, double quotation marks, parentheses, or beginning and ending braces

Operators?

Each data type is usually associated with specific operators, so certain operators can be used only with variables that are of a certain data type.

Expression and sub-expression?

Ex: Expression (x +10) * (u + v) contains the two sub-expressions (x +10) and (u + v).

Additive operators?

Perform addition(+) and subtraction(-). Ez:

EOF?

Short for End-Of-File, EOF is a code placed by a computer after a file's last byte of data. EOF marks are helpful in data transmission and storage. Files are stored in blocks, and the end marker helps the computer know it has allocated enough space to store the file.

Char?

The abbreviation char is used as a reserved keyword in a number of programming languages, such as C, C++, C#, and Java. It is short for character, which is a data type that holds one character (letter, number, etc.) of data. For example, the value of a char variable could be any one-character value, such as 'A', '4', or '#'.

The assignment operators?

These are used to assign the values for the variables in C programs. Ex: X=4

Increment and decrement operators?

These operators are used to either increase or decrease the value of the variable by one. Ex: x++, x--.

The bitwise opreators?

These operators are used to perform bit operations on given two variables.

Variables?

Think of a variable as a name of a location where the program can store some information. Because stored information can change, we use the term variable. A variable name is an identifier and therefore follows the rules for identifier names.

Binary operator Vs. Unary operator?

When + or - is used with two operands (e.g., x + y), it is referred to as a binary operator. When + or - is used with one operand (e.g., - y), it is referred to as a unary operator.

Input and Output Statements?

are needed to submit data to a program, and output statements are needed for a program to display any results that the program might have produced.

Synthesizing and Analyzing Code?

are two essential—but different—skills involved in dealing with programming

Arithmetic Operators (used with both ints and floats)?

are used with ints or floats and are grouped as follows (we assume that x, y, and z can be either ints or floats, except while discussing the % operator, where we assume that both x and y are positive ints).

Precedences and Associativities in Logical Operators?

associativity and precedence rules are used to simplify writing Boolean expressions. - ANDs and ORs have left-to-right associativity (like + and -), whereas NOT has right-to-left associativity (like ^). - In evaluating expressions, things inside parentheses are evaluated first, followed by NOTs, followed by ANDs, and finally followed by ORs.

double type?

double precision floating point type. Matches IEEE-754 64 bit floating point type if supported

Long double type?

extended precision floating point type. Matches IEEE-754 extended floating-point type if supported, otherwise matches some non-standard extended floating-point type as long as its precision is better than double.

Drive bays?

is a standard-sized area for adding hardware to a computer.

OR Operator?

is also a binary operator and is denoted by the symbol ||, which is two adjacent pipe symbols. x y x || y false false false false true true true false true true true true

Comment?

is any text in a program's code, script, or another file that is not meant to be seen by the user running the program. However, is seen when viewing the source code. - start with /* and end with */. - Comment is space.

Integral promotions conversion?

is clearly defined in following rule (6.3.1.1): If an int can represent all values of the original type, the value is converted to an int; otherwise, it is converted to an unsigned int. These are called the integer promotions. All other types are unchanged by the integer promotions.

A "character constant" ?

is formed by enclosing a single character from the representable character set within single quotation marks (' '). Character constants are used to represent characters in the execution character set.

Synthesizing Code?

is the ability to create programs using algorithms.

Analyzing Code?

is the ability to read and understand programs or algorithms that others have already written.

646 7 bit character set?

is the name of a set of ISO standards, described as Information technology — ISO 7-bit coded character set for information interchange and developed in cooperation with ASCII at least since 1964.

Associativity definition?

is used to decide the order of operations in expressions where the operators are all of the same kind—either all multiplication or all division. The operators +, -, * , /, % are all left associative. Thus, x + y - z (written without using any parentheses) is interpreted and executed as ((x + y) - z)

Precedence?

is used to decide the order of operations when expressions contain different operators. In this case, evaluate expressions in the following order. 1. Evaluate expressions inside parentheses. 2. Evaluate exponents. 3. Evaluate multiplications and divisions (use associativity within this step). 4. Evaluate additions and subtractions (use associativity within this step).

Multiplicative Operators?

operator operation example * multiplication x * y / division x / y % integer remainder x % y ^ exponentiation x ^ y

Additive Operators?

operator operation example + addition x + y + sign (unary operator) + y - subtraction x - y - sign (unary operator) - y

Multiplicative operators?

perform multiplication (*), division (/), and remainder (%) operations. Ex: 9/2==4

The C language represents numbers in how many forms?

three forms: integral( store numbers in the set of integers), real and complex (in real number in a floating point).

Semicolons?

to mark the end of a statement (including declarative statements for variables). A missed semicolon is a frequent source of compile-time errors in these languages.

Parentheses?

used to override the normal effects of precedence and associativity.

Mixing Arithmetic Operators?

we can mix the arithmetic operators and build complex expressions. Parentheses are used to denote groupings (i.e., which operations should be performed first). (x + y) * (u + v) is different from x + y * u + v


Ensembles d'études connexes

Study guide lesson 2 Medicare/Medicaid MBC_40

View Set

QuickBooks Online Certification: Sample questions

View Set

Chapter 26: Drugs Used to Treat Thromboembolic Disorders

View Set

Ch. 9 homework questions: Microeconomics

View Set