Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
do something.
Object Program - The source program after it has been translated into machine
language.
Translator Program - The program that translates the source program into the object
program. Can be either a compiler or an interpreter.
Compiler - spends some time evaluating the entire program and then translates all the
programming statements of a program into a machine language program, which is then
executed at once.
Categories of Programming
Systems programming involves writing programs that enable a computer to carry out its
basic internal functions as well as some other specialized functions.
1. Problem statement
2. Algorithm development
3. Program coding
4. Program testing
5. Program documentation
Common Programming Errors
1. Syntax Errors
- occurs when your code violates one or more grammar rules of C and is detected by
the compiler as it attempts to translate your program.
2. Run-time Errors
- are detected errors and displayed by the compiler during the execution of the program.
- occurs when the program directs the computer to perform illegal operation, such as
dividing a number by zero
3. Logic Errors
C History
C Language
C Language Elements
The C Preprocessor - a program that is executed before the source code is compiled.
DIRECTIVES – how C preprocessor commands are called, and begin with a pound /
hash symbol (#).
- causes the preprocessor to insert definitions from a standard header file into the
program before compilation.
- tells the preprocessor that some names used in the program are found in the standard
header file.
2. #define – allows you to make text substitutions before compiling the program.
- by convention, all identifiers that are to be changed by the preprocessor are written in
capital letters.
Function Main
Every C program has a main function. This is where program execution begins.
1. Declarations
– the part of the program that tells the compiler the names of memory cells in a program
needed in the function, commonly data requirements identified during problem analysis.
2. Executable statements
– derived statements from the algorithm into machine language and later executed.
a reserved word is defined as the word that has special meaning in C and cannot be
used for other purposes.
Punctuation Marks
- associated with a memory cell whose value can change as the program executes.
Variable declaration
– statements that communicate to the C compiler the names of all variables used in the
program and the kind of information stored in each variable.
Data Type – a set of values and a set of operations that can be performed on those
values.
1. Text (data type char) – made up of single characters (example x,#,9,E) and strings
(“Hello”), usually 8 bits, or 1 byte with the range of 0 to 255.
3. Floating-point values – numbers that have fractional portions such as 12.345, and
exponents 1.2e+22.
6. Void – signifies values that occupy 0 bit and have no value. You can also use this
type to create generic pointers.
7. Pointer – does not hold information as do the other data types. Instead, each pointer
contains the address of the memory location.
double - data type double is used to define BIG floating point numbers. It reserves twice
the storage for the number. On PCs this is likely to be 8 bytes.
- short
- long
- signed
- unsigned
Constants
– identifiers that are having a constant value all throughout the program execution.
Examples:
3. Floating constants – require the use of decimal point followed by the number’s
fractional components. Ex. 16.234
4. String constants – set of characters enclosed by double quotes. Ex. “bag” and “this is
good”
Defining Constants
Operators
Assignment Operator
– Equal sign (=) - the most basic assignment operator where the value on the right of
the equal sign is assigned to the variable on the left.
+, -, *, /, %
Prefix increment is when the ++ is placed immediately in front of its operand. the value
of the expression is the variable’s value after incrementing.
Postfix increment is when the expression’s value is the value of the variable before it is
incremented.
double %f %lf
float %f %f
unsigned int %u %u
int %d %d
short %hd %hd
char %c %c
String - %s
scanf() – one of the Turbo C object stream object that is used to accept data from the
standard input, usually the keyboard.
getch() – allows the user to input a character and wait for the enter key. Inputted char
will not be echoed but could be stored if location is specified.
getche() – allows the user to input a character and there is no need for the enter key.
Inputted char will be echoed but could be stored if location is specified.
printf – writes formatted output to the standard output device such as the monitor.
puts – writes the string to the standard output device such as the monitor and positions
the cursor to the next line.
Control Flow
3 Types:
1. Sequential
2. Conditional
3. Iterative
Sequential - organized such that statements are executed in sequence, i.e., one after
the other in the order of their appearance in the source code.
1. Communication.
2. Effective analysis
3. Proper documentation
4. Efficient coding flowcharts act as a guide or blueprint during the system analysis and
program development phase.
Limitations of flowcharts
1. Complex logic – sometimes the logic is quite complicated, which makes flowchart
becomes complex and clumsy.
2. Alteration and Modifications – if alterations are required, the flowchart may require re-
drawing completely.
4. The essentials of what is done can easily be lost in the technical details of how it is
done.
Flowchart Symbols:
5. Decision Symbol - denotes a point in the program where more than one path can be
taken or used to designate a decision making process. Algorithms and Flowcharting
Flowchart Symbols:
6. Flow lines and Arrowheads - used to show reading order or sequence in which
flowchart symbols are to be lead. - show the direction of processing of data flows.
7. On-page Connector - non processing symbol - used to connect one part of the
flowchart to another without drawing flow lines within page. A A Denotes an entry
Denotes an exit Algorithms and Flowcharting A A Flowchart Symbols:
8. Off-page Connector - non processing symbol - used to connect one part of the
flowchart to another without drawing flow lines not within the same page.
A system flowchart shows in general terms the operations that will be performed on
information in an information system
High-Level Flowchart
Detailed Flowchart