Computer Programming I
Computer Programming I
ALGORITHM DEVELOPMENT
- similar to steps in flowchart
PSEUDO CODE
- mixture of language and symbols,
terms and other feature commonly
used one or more high-level
languages
ALGORITHM STRUCTURE
- displayed in a structure diagram
how one will be performed
- useful in describing algorithms for
more complex problem
- translation of program executed b
Computer Dennis Ritchie (1972)
expanded B to C language, computer
Programming I added data types
SOURCE CODE
Borland International
CHAPTER 2: introduction Corporation (1987) developed - text of program that user can read
to c a version of C called Turbo C
for microcomputers/IBM
LIBRARY
- high-level language concentrating - reads entire program and converts b) Logic Error
problems at hand to code executed by computer - incorrect use of control structures
[ COMPONENTS OF TURBO C ]
ELEMENTS OF C LANGUAGE
1. Editor
a) Identifiers b) Data Types
– create program source code
- names used to reference variables, Type Use Value
2. Extended C Language functions, labels, and various user- Integer Whole Long int:
defined object (int) number -214748364
– C is extended from base bone of consisting 8 to +
Ritchie’s specifications. - sequence of digits, letters, and of + or – 2147483647
underscore ONLY. and do
- enhancement; compatible to ANSI
Standard not have Short int:
commas -32768 to
3. Compiler [ RULES IN NAMING IDENTIFIERS ] +32767
Float A sign of 3.4 E to -38
- convert source code into machine + or -, to 3.4 E to
code or binary code followed +38
1. First character must be LETTER or
4. Debugger by digit
UNDERSCORE with subsequent
with 7 digits
letters, numbers, or underscore. May decimal
- for testing program and locating
not have space or hyphen point
programming errors
2. Consist only of alphabetic char, Double Higher 1.7 E – 308
5. Run precision to 1.7 E
digits, or underscores
than +308
- time environment; capability for
3. First 63 characters of identifier are float,
running programs within Turbo C
significant. Upper and Lower Case have 15 digits
6. User Interface are different from one another longer
exponent
- allows you to smoothly proceed 4. Must not be the same with C Char Single -128 to 127
from source – code to entry to keyword, must not have same name Quotation
for letter, Unsigned
double char is from The assignment operator directs C to
for strings 0 to 255 assign to the variable on the left side
Void Valueless - VARIABLE INITIALIZATION the value on the
Note: Unsigned char is to increase - process of assigning, starting values right side.
byte size, char a[no.] is for strings to variables
[ STEPS IN INITIALIZING VARIABLES ] GLOBAL VARIABLES
[ THREE USES OF VOID ]
- at the start of program
1. To declare explicitly a function as
1. Assignment statement (=) to - are initialized to zero if no other
returning no value.
assign values to variables of any initializer is specified
2. To declare explicitly a function
types - declared OUTSIDE functions of
having no parameters.
EX. int num = 24; computer program
3. To create generic pointers.
2. By using function scanf (user LOCAL VARIABLES
c) Variables
input) - initialized each time the function in
- are identifiers which can be
EX. scanf (“%d”, &num); which they are declared is entered
assigned a value within a program.
- declared INSIDE function of
- 32 valid characters (letters, digits,
3. By assigning values during program
underscore)
declaration
EX. double num1 = 124.09; d) Constants
VARIABLE DECLARATION
- fixed values that may not be altered
- used to name an object
[ HOW TO ASSIGN VALUES TO by program
- the declaration gives them symbolic
VARIABLES ] - Literal Constants if Turbo C
name and definition reserves
memory for them
1. The variable must be on the left CHARACTER CONSTANTS
- usually found at the beginning of
side of the equal sign. Values must - enclosed in single quotes
the statement
be on the right side of the
equal sign. INTEGER
EXAMPLE: int x, y, z;
2. Any expression can be assigned on - number without fractional
char a, b ;
the variable. components
double s;
3. Expressions are not allowed on the
float ave;
left side of the assignment operator. FLOATING-POINT
char Sname[30];
- requires use of decimal point EX.: - requires two operands like addition
followed by fractional component const float version = 3.20; or multiplication