Sie sind auf Seite 1von 10

1.

The Copyright law protects the original work of autorship and it applies automatically to an original work from
the day it is created until 50 years after the owner's death. Copyright protection means that the owner of the
copyright has the exclusive right to make, use, and sell the original work.
2.A software trademark is any word, name symbol, device or any combination thereof adopted and used by a
manufacturer or merchant to identify its goods and to distinguish them from the goods manufactured or sold by
others.
3.Bit: 0 or 1; Byte: typically 8 bits; Word:machine dependent, a number of bytes.
4. 1kb=1024 bytes; 1MB=1024kb; 1GB=1024MB
12kB=12*1024 bytes=12.288 bytes
3GB=3*1024MB=3.072MB=3.072*1024kb=3.145.728 kb=3.145.728*1024bytes=3.221.225.472 bytes
128MB=128*1024kb=131.072kb=131.072*1024bytes=134.217.728bytes
5.An Interactive Development Environment consists of text editors, translators (assemblers,compilers,interpreters)
and the debugger.
6.The stages needed to produce an executable program from sources are: compilation (the source code is
transformed into relocatable object code), linking (many relocatable binaries are made into one relocatable binary
with all external references satisfied), loading (the relocatable is transformed into absolute binary with all code and
data references bound to the adresses occupied in memory) and execution (control is transferred to the first
instruction of the program).
7. The stages of the compilation process are:
-Lexical analysis (scanning),when the source text is broken into tokens.
-Syntactic analysis (parsing),when the tokens are combined to form syntactic structures, typically represented by a
parse tree. The parser may be replaced by a syntax-directed editor, which directly generates a parse
tree as a product of editing.
-Semantic analysis, when the intermediate code is generated for each syntactic structure.The type checking is also
performed in this phase.
-Machine-independent optimization,when the intermediate code is optimized
to improve efficiency.
-Code generation,when the intermediate code is translated to relocatable
object code for the target machine.
-Machine-dependent optimization,when the machine code is optimized.
On some systems (e.g., C under Unix), the compiler produces assembly
code, which is then translated by an assembler.
8.
-preprocessor-(Source w/Substitutions)-Parser-(Parse tree)-Translation-(Assembly)-Assembler- - ...-(Object file)Linker-(Exe File)-DISK-(Exe File)-OS Exe Loader-(Memory Image)

9. program=a program consists of data description and procesing statements.


programming=or program development, consists of algorithm development and coding in an appropiate
programming language.
10. The basic requirements for a well-posed problem are: the known information has to be clearly specified, we
have to be able to determine when the problem has been solved and the problem must not change during its
attempted solution.
11. The results of the analysis stage are: a clear and precise statement of the problem to solve (the function of the
program), input data specification, output data specification and Input/Output data organization on the media.
12. Program design is the elaboration of an algorithm to achieve the function of the program.
13. The benefits of modularity are the following: the capability of decomposing a complex system into simpler
pieces, the capability of composing a complex system from existing modules,the capability of understanding a
system in terms of its pieces and the capability of modifying a system by
modifying only a small number of its pieces.
14.Top-down: Suppose we are given the program to design P, which will accomplish function F. First, we decompose
F into a number of sub-functions (F1,F2,F3,...) provided that F is completely fulfilled by these functions. Then the
modules P1,P2,P3... result, accomplishing F1,F2,F3,... .Now we have the module P, called the main program, which
describes the relation between P1,P2,P3... and in this way we can start from the top (the general problem) and
proceed down, to details. If the function f is simple enough we can represent it directly, otherwise we have to
further decompose it into modules, resulting in a tree structure.
15.Bottom-up: In this case we start at the lowest levest (highest detail) with code modules with specific functions
and we combine the modules to obtain overall functionality. In this case the structure is that of a tree, built from
the leaves. For each module we must determine its logic, write the code and then test it, that is design driver
programs for testing each module. After testing we must integrate and test the complete application. In the case of
the Bottom-up programming technique, the most frequent errors are the integration errors (communication among
modules).
16.The benefits of top-down program-design are the following: the modules for each hierarchy level are fully tested
and integrated with preceding program units, ahead of coding lower levels and the ease of code changes,because
most changes are done at lower levels, the last ones to code.
17.The stages of program implementation are the following: coding of each module in a programming language,
Editing the source code using a text editor, translation of the source code into object code and debugging
syntax errors (these translators can be assemblers or compilers), link editing to obtain a memory image (executable
code) of the program and debugging link editing errors and, finally, loading into the core memory, running the
program and debugging logic errors.
18. Program documentation is used for maintenance and program usage. As far as its contents are concerned,
program documentation consists of: problem statement and I/O data specification, a presentation of the solution of
the problem, program design (modular structure and inter-module relationships, description of the logic of each
module), source code listing, input and output data used in testing and operation instructions concerning data
package structure, I/O formats, error messages, media requirements (mounting of disks, tapes, etc.)

19. During program maintenance one must make changes for error correction discovered during program usage,
make changes in order to adapt to new requierments. Program documentation is especially important for this stage
and this documentation must be continually updated to reflect changes.
20. Given both the problem and the device, an algorithm is the precise characterization of a method of solving the
problem, presented in a language comprehensible to the device. An algorithm should have the following properties:
application of the algorithm to a particular input set or problem description results in a finite sequence of actions,
the sequence of actions has a unique initial action, each action in the sequence has a unique successor, the
sequence must terminate with either a solution to the problem, or a statement that the problem is unsolvable for
that set of data.
21. The general requirements for an algorithm are the following: finiteness (potential realizability), which means
that the algorithm must terminate after a finite number of stepts, well-defined, meaning that each of the steps is
expressed non-ambiguously, effectiveness, which refers to the fact that the running time should be as short as
possible, and the memory requirements as low as possible and universality in order to allow for a class of problems
to be solved using it.
22. Flowcharts graphically depict the logical steps to carry out a task and show how the steps relate to each other.
They are made using geometric symbols connected by arrows and within each symbol is a phrase presenting the
activity at that step.The shape of a symbol indicates the type of operation
that is to take place. Flowcharts ensure a good presentation of tasks and are easy to follow, but they are timeconsuming to write and update.
23. Pseudocode uses English-like statements which outline a particular task
or process. It is considered to be a short version of the actual computer code, which can be easily translated into a
programming language, it is compact and looks a lot like the final code.
24. Hierarchy charts are similar to a company's organization chart and they display the overall program structure,
describe what each module does and the relations between modules. It is mainly used for initial planning of a
program by creating independent parts and it is read from top to bottom and from left to right,
25.A control structure is a programming language construct which specifies a
departure from the sequential execution patternThe types of control structures used in describing algorithms are:
sequence, decision and loop.
26.Selection is a control structure allowing for the selection of one of many possible alternatives and it can be
achieved by using more decision controls.
case (expression) of
c1,{c1}:sequence1;
c2,{c2}:sequence2;
...
cn,{cn}:sequence n;
rest:sequence_rest; {optional}
endcase;
( expression is of ordinal type)
The first step is to evaluate the expression "expression". Then execute the label ci equal to the value of the
expression and then execute the statement following the block case-endcase. If no label has the value of the
expression, execute the optional sequence labeled rest and then the statements following the block case-endcase.
If neither condition

is met, the case is ineffective.

26. A loop expresses a group of statements which are repeatedly executed,


depending on a condition or a counter.
while (condition) do
begin
sequence
end

The first step is for the condition to be evaluated. If result is false, the loop execution is ended, otherwise the
sequence is executed and then go back to the first step. The loop may never be executed if the condition is initially
false and in order for the loop to terminate, the sequence must contain statements which alter the value of
condition.
27. A loop expresses a group of statements which are repeatedly executed,
depending on a condition or a counter.
The first step is to execute the sequence. Then the condition is evaluated. If the result is false then it goes back to
the first step, otherwise the execution is continued with statements following this control. The loop body is
executed at least once.
repeat
sequence
until (condition)

28. for control_var:=initial_expr to|downto final_expr do


begin
sequence
end
Steps when executing a for loop:
Step1. Evaluate e1:=initial_expression
Step2. Evaluate e2:=final_expression
Step3. Assign to e1 to control_var
Step4. Evaluate the logic expression
control_var<=e2 for to form
control_var>=e2 for downto form
Step5. If the result of the evaluation of Step4 is false,
terminate loop execution. Otherwise go to Step6.
Step6. Execute sequence
Step7. control_var takes the successor value for the
to form or predecessor value for the downto form.
Step8. Go to Step4.

Notes
Control variable is of ordinal type
Initial and final expression are evaluated only
once
Loop body may never get executed
 For the downto variant
Test becomes: control_var>=e2
The control variable is decremented
29. The formal parameters are given as:
in identifier {, in identifier}:type
out identifier {, out identifier}:type
inout identifier {, inout identifier}:type
in parameters are input parameters for the procedure,
whose values cannot be changed inside the procedure
body, or, if changed, is not passed to the caller
out parameters are output parameters for the procedure,
whose values is computed inside the procedure body, and
is returned to the caller
inout parameters are parameters whose values are
changed inside the procedure body, the old value is lost,
and the computed value is passed back to the caller.
30. Programming style is a set of general rules concerning the form of a program, and its implementation details. It
is characterized by marking out the structure of a program, program modularity, data abstraction, program clarity,
ease of further changes, error handling, generality of the solution.
31. Some reccomendations for a good programming style are the following: choosing meaningful names for
variables, constants, functions, etc., use comments and indenting to relieve flow control, avoid forced exit from
loops, avoid using globals and use as few auxiliary variables as possible, avoid changing a for loop control variable
inside the loop body. Furthermore, one shouldnt use un-initialized variables, should check ranges for variables,
avoid unclear tricks, use symbolic constants, follow the algorithm when coding and postpone formatting of output
until you get the output correct, but it must not be forgotten.
32. A program is composed of one or more functions, of which one is mandatory: function main. The other defined
functions are user-defined. A C program has the following form:
- Preprocessor Commands
- Type definitions
- Function prototypes -- declare function types and variables passed to a function.
- Variables
- Functions
33. Integer Type Sizes (bits)
type
linux on a pc ibm pc windows xp/nt ansi c minimum
char
8
8
8
int
32
32
16
short
16
16
16
long
32
32
32

long long

64

64

64

34. Primitive types in C:


- char: size>=8 0~127
- signed char: same as char -127~127
- unsigned char: same as char 0~255
- short: >=16,>=size of char -32.767~32.767
- unsigned short: same as short 0~65.535
- int: >=16, >=size of short -32.767~32.767
- unsigned int: same as int 0~65.535
- long: >=32,>=size of int -2.147.483.647~2.147.483.647
- unsigned long: same as long 0~4.294.967.295
- bool: >=size of char,<=size of long (true/false)
- wchar_t: >=size of char, <=size of long
- float: >=size of char
- double: >=size of float
- long double: >=size of double
- type& >=size of char
- type* (pointer) >=size of char
36. A constant has a type and a value which cannot be changed during run time.
Integer constants:
- Decimal: string of decimal digits optionally preceded by a sign.
To indicate length and signed ness:
L, l: long
U, u: unsigned
UL, ul, LU, lu: unsigned long
EX: 100, 100L, 100U, 100ul
- Octal:
Begin with a zero and contain only octal digits
Are unsigned or unsigned long
EX: 0144 (=100 decimal), 0176 (=126)
- Hexadecimal:
Begin with 0x or 0X and contain only hex digits
Are unsigned or unsigned long
EX: 0xab1 (=2737 decimal)
38. Escape sequences in C
SEQUENCE
\a
\b
\f
\n
\r
\t
\v
\'

MEANING
Alert (ANSI C)
Backspace
Form feed
New line
Carriage return
Horizontal tab
Vertical tab
Single quotation mark

\"
\\
\?
\ ooo
\x hh

Double quotation mark


Backslash
Question mark
Octal value. (o represents an octal digit)
Hexadecimal value. (h represents a hexadecimal digit)

39. Conditional compilation facilitates development, mainly testing. Conditional compilation can be
achieved with the help of conditional compilation symbols which can be used to affect compilation.
(1) #if expr
text
#endif

#if expr
text1
#else
text2
#endif
expr=constant expression which can be evaluated by the preprocessor
text, text1, text2=portions of a source code
effect: if expr is not 0 text(text1) are compiled (not text2), otherwise only text2(for second form)
and processing continues after #endif

(2) #ifdef name


text
#endif

#ifdef name
text1
#else
text2
#endif
name=a constant which is tested if defined
text, text1, text2=portions of a source code
effect: if name is defined text(text1) are compiled (not text2), otherwise only text2 (for second
form) and processing continues after #endif
(3) #ifndef name
text
#endif

#ifndef name
text1
#else
text2
#endif
name=a constant which is tested if not defined
text, text1, text2=portions of a source code
effect: if name is undefined text(text1) are compiled (not text2), otherwise only text2 (for second
form) and processing continues after #endif

#ifdef and #ifndef are used to avoid multiple inclusions. Thus at the beginnig of each header file sequence
similar to the following can be present (except from stdio.h)
40. A preprocessor define directive directs the preprocessor to replace all subsequent occurrences of a
macro with specified replacement tokens. The #define directive can be used to create a name for a
numerical, character, or string constant.
#define name character_sequence
During preprocessing, name is replaced by character_sequence. The #define directive causes the compiler
to substitute character_sequence for each occurrence of name in the source file. The name is replaced
only when it forms a token. That is, name is not replaced if it appears in a comment, in a string, or as part
of a longer identifier.This replacement continues until a directive #undef name or the EOF is met.

41. Macros are essentially shorthand representations of arbitrary sections of the source code, which
makes the source code succinct, while its (the macro template's) expansion replaces each of its presence
prior to compilation. Whatever is there to do with Macros, it is done by the preprocessor, so that the
source code is ready for compilation. Function is a calling routine, whence a large program is divided into
separate portions, each portion doing a separate job, and proper calling of these portions in different
places combines the works done by them into the required complete output. Thus functions have nothing
to do with the preprocessing period, they are just compiled.
Function invocation involves a call and execution of statements of function body and, upon function
invocation, parameter type is also considered. Macro invocation means expansion, replacement of
invocation with macro text. Thus statements in a macro are generated for each invocation and compiled.
Hence, macros should be used for small size computations. Upon macro invocation, a formal parameter
is replaced by the character sequence corresponding to the actual parameter. Formal-actual parameter
correspondence is purely positional. Processing time is shorter when using macros (function
invocation requires overhead.
42. #ifndef is a directive for conditional compiling.
#ifndef name
text
#endif

#ifndef name
text1
#else
text2
#endif
name=a constant which is tested if not defined
text, text1, text2=portions of a source code
effect: if name is undefined text(text1) are compiled (not text2), otherwise only text2 (for second
form) and processing continues after #endif
#ifdef and #ifndef are used to avoid multiple inclusions of header files in C. Thus at the beginning of each
header file sequencessimilar to the following can be present:
#ifndef _STDIO_H_
#define _STDIO_H_
......
#endif
There exist a number of predefined names:
__MSDOS__ if operating system is MSDOS
__DATE__ date of compilation
__CDECL__ -indicates that function calls follow C conventions
__STDC__ - defined if strict C ANSI rules must be followed
__FILE__ - name of currently compiled file
44. A functional algorithm must be finite, that is the algorithm must terminate after a finite number of

steps. Even if an algorithm satisfies the above criterion it may not be a practical way of solving a
problem. While an algorithm may execute in a finite time it is not much use if that finite time is so large
as to make solution completely impractical. Thus there is a lot of interest in finding `good' algorithms
which generate correct solutions in a short time compared with other algorithms.
46. A constant has a type and a value which cannot be changed during run time.
Integer constants:
- Decimal: string of decimal digits optionally preceded by a sign.
To indicate length and signed ness:
L, l: long
U, u: unsigned

UL, ul, LU, lu: unsigned long


EX: 100, 100L, 100U, 100ul
- Octal:
Begin with a zero and contain only octal digits
Are unsigned or unsigned long
EX: 0144 (=100 decimal), 0176 (=126)
- Hexadecimal:
Begin with 0x or 0X and contain only hex digits
Are unsigned or unsigned long
EX: 0xab1 (=2737 decimal)
Character constants have their ASCII code as a value and int as a type.
52. The function gets reads characters from the stream stdin up to the next newline character, and stores
them in the string given as argument: char *gets(char *s). The newline character is discarded and if gets
encounters a read-error or end-of-file, it returns a null pointer; otherwise it returns its argument. The gets
function can be very dangerous, because it provides no protection againstoverflowing the string s. The
GNU library includes it for compatibility only. One should always use fgets or getline instead.
53. An expression is formed of one or more operands joined by operators. An operand has a type and a
value and it can be: a numeric or character constant, a symbolic constant, a simple variable identifier, an
array identifier, a structure identifier, a type identifier, a function identifier, an indexed variable, a
component of a structure, a function call or an expressions enclosed between paranthesis.
54.When evaluating an expression the following are taken into account:
- operator priority
- operator associativity for equal priority
- default conversion rule
- descending order of type priority (long double, double, float, unsigned long, long, unsigned int, int)
- the result of evaluating relational expressions is true (non-zero) or false (zero)
- increment and decrement operators can be prefixed (++operand) or postfix (operand--);
- in case of the coma operator, the expressions are avaluated strictly from left to right and their values
discarded, except for the last one, whose type and value determine the overall expression.
55. The relational operators are: <, <=, >, >=;
68. The major difference between a while and a do-while statement is the fact that while is an entrycontrolled loop and do-while is an exit-controlled loop, thus the do-while loop will be executed at least
once, while in the case of the while loop, the loop condition has to be initially TRUE for body to be executed
74. The expression of a switch statement can be an integral or string type expression.
75. A preprocessor define directive directs the preprocessor to replace all subsequent occurrences of a
macro with specified replacement tokens. The #define directive can be used to create a name for a
numerical, character, or string constant.
#define name character_sequence
During preprocessing, name is replaced by character_sequence. The #define directive causes the compiler
to substitute character_sequence for each occurrence of name in the source file. The name is replaced
only when it forms a token. That is, name is not replaced if it appears in a comment, in a string, or as part
of a longer identifier.This replacement continues until a directive #undef name or the EOF is met.

77.
#ifdef and #ifndef are used to avoid multiple inclusions of header files in C. Thus at the beginning of each
header file sequencessimilar to the following can be present:
#ifndef _STDIO_H_
#define _STDIO_H_
......
#endif
There exist a number of predefined names:
__MSDOS__ if operating system is MSDOS
__DATE__ date of compilation
__CDECL__ -indicates that function calls follow C conventions
__STDC__ - defined if strict C ANSI rules must be followed
__FILE__ - name of currently compiled file
82. The comma operator (,) is used to separate two or more expressions that are included where only one
expression is expected. When the set of expressions has to be evaluated for a value, only the rightmost
expression is considered. In case of the coma operator, the expressions are avaluated strictly from left to
right and their values discarded, except for the last one, whose type and value determine the overall
expression.
90. The statements in C which can cause a program to become unstructured are: goto, continue, break (in
loops) and exit. Thus, their usage is not recommended.
91. The exit standard function is used for forced termination of program execution. A return code of zero
means normal termination and other values mean errors. The prototype for exit is found in stdlib.h and
process.h: void exit (int code);
n=scanf(%d%d%f%f,&i,&j,&a,&b);
If (n!=4) exit(1); /forced exit with code 1/
92. One can achieve forced program termination by using the exit standard function.

Das könnte Ihnen auch gefallen