0% found this document useful (0 votes)
39 views

Computer Programming I

This chapter introduces some key concepts in computer programming: 1. It defines a computer as an electronic device that accepts data from users, processes it, produces results, and stores data for future use. 2. Programming involves writing instructions for a computer in a specific programming language. It is done through a process of defining the problem, designing a solution, coding the program, testing it, and documenting it. 3. Key concepts discussed include data, information, hardware, software, systems software, application software, algorithms, pseudo-code, flowcharts, and program logic. 4. The chapter outlines the steps for programming which include problem definition, program design, coding, testing, and documentation. Programming

Uploaded by

Claret Amor
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Computer Programming I

This chapter introduces some key concepts in computer programming: 1. It defines a computer as an electronic device that accepts data from users, processes it, produces results, and stores data for future use. 2. Programming involves writing instructions for a computer in a specific programming language. It is done through a process of defining the problem, designing a solution, coding the program, testing it, and documenting it. 3. Key concepts discussed include data, information, hardware, software, systems software, application software, algorithms, pseudo-code, flowcharts, and program logic. 4. The chapter outlines the steps for programming which include problem definition, program design, coding, testing, and documentation. Programming

Uploaded by

Claret Amor
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

control computer’s operation, input, EXAMPLES: MS Apps (Word), Oracle

Computer and output. PROGRAMMING


Programming I - Collection of several components - Act of writing instructions that
working together. Some are consist of statements in a form of
CHAPTER 1: essential, some for advancement. specific programming language
EXAMPLES: CPU, Keyboard, Mouse,
Programming Concepts Hard Disk, Printer, Scanner, External [ 5-STEP PROCESS OF
COMPUTER Hard Disk, Monitor, Speaker PROGRAMMING ]

- An electronic device that accepts PROGRAM 1. Define the problem


data from user, processes it, - A set of instructions that drives 2. Design the solution or program
produces results, displays them to computer to do stipulated tasks 3. Code the program
users, and stores result for future 4. Test the program
usage. SOFTWARE 5. Document the program
- Instructions are programmed in a
DATA computer language, translated into [ PROBLEM-DEFINITION STEPS ]
- A collection of unorganized or machine language, and executed by
unstructured facts and figures computer 1. Specify program objectives and
- Does not only provide information identify the users of the program.
regarding patterns, contexts, etc. [ TWO TYPES OF SOFTWARE ] 2. Specify the output requirements.
a) System Software 3. Specify the input requirements.
INFORMATION - operates directly on hardware 4. Specify processing requirements.
- A structured data (organized devices of computer 5. Study feasibility of implementing
meaningful and processed data) - provides platform to run an the program.
- A computer is used to process data application, supports user 6. Document the analysis.
and convert it into information functionality
EXAMPLES: Operating Systems [ PROGRAM DESIGNING ]
HARDWARE (Windows, Linux, Unix, etc.)
- Mechanical device that makes up 1. Determine the program logic
computer. b) Application Software through top-down approach and
- Consists of interconnected - designed for benefit of users to modularization, using
electronic devices that we can use to perform one or more tasks. hierarchy charts.
2. Design details using pseudo-code a) Desk Checking: existing system. Maintenance here
and/or flowcharts. - Verifying the programming and means keeping the programs in
3. Test design with a structural logic of an algorithm before working conditions, error free and up
walkthrough. Structural walkthrough launching to date.
consists of reviewing process with
other programmers and system b) Debugging PROGRAM LOGIC FORMULATION
analyst and scrutinize - Detecting, locating, removing errors - step-by-step development of
(“walkthrough”) the programmer’s in program solution to given problem (most
work. difficult)
c) Running Data - after a method, translate this to the
PROGRAM CODING required language (ex. C language)
- step which translates logic of the
program based on the pseudo-code PROGRAM DOCUMENTING FLOWCHART
(algorithm) or flowcharts in high-level - written descriptions of what - consists of shapes that contain
programming language program is all about and how to use simple statements called
- use syntax and semantics of instructions and are connected
specific language [ STEPS FOR DOCUMENTATION ]

NOTE: Coding is a subset of 1. Write user documentation. This is


programming. Coding is writing lines the manual that is prepared to help
of codes, while programming creates the user use the programs.
executable machine program 2. Write operator documentation.
This manual gives the computer
[ STEPS IN PROGRAM CODING ] operator information on what to do
when the program flashes an error
1. Determine the appropriate message.
programming language to use. 3. Write program documentation.
2. Code the program in the specific The program documentation consists
programming language decided on. of the testing of the whole programs.
This documentation helps train the
new programmers to maintain
PROGRAM TESTING
SYMBOLS IN FLOWCHARTS SHAPES IN FLOWCHARTS FLOWCHART DEVELOPMENT
- steps that compromise flowchart
DATA INDICATION must be organized
Stored Data Data formatted
suitable for STRUCTURED FLOWCHART
processing - an orderly, understandable, and
Sequential Sequentially clear solution
Access Storage accessible data - has 3 basic methods of control as
(e.g., cassette) guide to produce correct and
Direct Access Directly
necessary program
Storage accessible data
(e.g., floppy d.)
Documents Data humans [ BASIC METHODS FOR STRUCTURED
can read FLOWCHART ]
Display Displayed data
on any medium 1. Sequential (STRAIGHT)
Loop Limit Start and end of - simplest method of control, easy to
loop understand and develop
respectively - strictly sequential manner; step
Terminal Starting and executed one by one
Symbol ending point
Input / Output Enter data into 2. Selection (YES OR NO)
Symbol computer than - includes several alternative actions
display result selected and executed depending on
Processing Data processing TYPES OF FLOWCHARTS condition
Symbol operations a) System Flowchart - involves use of decision (diamond)
required from - indicates a flowchart for a targeted and alternative action represented by
problem system as a whole processing block
Decision Contains
Symbol condition b) Program Flowchart
Arrowheads / Used to direct 3. Repetition (LOOPS)
- used to describe processing - one or more steps are performed
Flow Lines flow of procedures based on detailed repeatedly
flowchart
analysis ALGORITHM
Connector Continuation
symbol
Initialization Variables
defined in input
- set or series of instruction for
carrying a task in English language
- procedure to produce required
output from given input
- subsequent to flowcharts

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

C LANGUAGE - collection of pre-written


INTERPRETER
- A general-purpose programming - reads source code of program and
language featuring economy of perform instructions one line at a [ TYPES OF ERRORS ]
expression, modern control flow, and time
data structures and operations a) Syntax Error
- “System programming language”: - typographical, incorrect format
useful for writing compilers and OS COMPILER - detected during compiled time

- 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

c) Runtime or Semantic Error


BRIEF HISTORY COMPILE TIME - not able to perform operations
- occur during compilation while program is running
 Martin Richards (1967)
developed Basic Combined d) Linker Error
Programming Language or - occurs when executable files are
BCPL RUN TIME
not found nor created
 Ken Thompson (1970) - occur while program is executing
developed B for UNIX System TURBO C
- more than version of C language
OBJECT CODE 0R BINARY CODE
- includes complete environment to compilation to debugging to running as function (e.g., integer, float,
create, test, and run programs without leaving Turbo C double, etc.)

[ 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

2. Using # define 3. Combined Operators


e) Operators - C’s shorthand operation
STRING or LITERAL STRING - symbol that tells the compiler to 4. Increment or Decrement
- consists of phrase enclosed within perform specific mathematical, - If the operator follows its operand, C
double quotations, text messages relational, or logical manipulations uses the operands value before
incrementing or decrementing it.
DEFINED DECLARATION (# DEFINE) ARITHMETIC OPERATORS Lvalue (left value): an object that has
- declares constants throughout the Symbol Use an identifiable location in memory
program, found after the header file * (Asterisk) Multiplication Rvalue (right value): no identifiable
library / (Slash) Division location in memory
+ Addition EX.
EXAMPLE: - Subtraction X = 10;
#include <stdio.h> -- (Unary Minus) Negation Y = ++X; (pre-increment, add agad 1)
#define price 500 % (Modulus) Gets remainder [ RESULT: X is 11, Y is 11 ]
#define pi 3.14 ++ Increment, add
one to value X = 10;
MODIFIER -- Decrement, Y = X ++; (post-increment, X is still
subtract one
- alter the meaning of the base type same as Y dahil di nag-add ng 1)
() Parenthesis
to more precise need of situation [ RESULT: X is 11, Y is 10 ]
1. Unary Operators
ACCESS MODIFIERS RELATIONAL OPERATORS
- requires single operand
1. Const - relationship values can have with
UNARY PLUS: no change to quantity
- variables under this modifier can’t one another, determine relationship
after
be changed during program of quantity
UNARY MINUS: causes sign of
execution
following quantity to be changed
- initial value before start Symbol Indication
SYNTAX: > Greater than
2. Binary Operators
const <data-type> variable = value; < Less than
>= Greater than or
equal to LOGICAL TABLE FOR NOT (!)
<= Less than or 1ST Result
equal to Condition
== Equal to TRUE FALSE (0)
!= Not equal to FALSE TRUE (1)
LOGICAL OPERATORS TERNARY OPERATORS
- ways relationships can be - uses question mark and colon
connected using rules SYNTAX: Expression1 ? Expression2:
Expression 3;
Symbol Indication
&& And Expression 1 = 1st condition
|| Or Expression 2 = Represents true
! Not (negate) Expression 3 = Represents false
1 True
0 False EXAMPLE: 7 == 3 ? 4 : 3
ANSWER: 3 (expression 2) because
LOGICAL TABLE FOR AND (&&) condition is false
1st 2nd Result
Condition Condition COMMA OPERATORS
TRUE TRUE TRUE (1) - used to string together several
TRUE FALSE FALSE (0) expressions
FALSE TRUE FALSE (0) - separate 2 expressions
FALSE FALSE FALSE (0)
EXPRESSIONS
LOGICAL TABLE FOR OR (||)
- combinations of operators,
1st 2nd Result
constants, variables
Condition Condition
TRUE TRUE TRUE (1)
TRUE FALSE TRUE (1)
FALSE TRUE TRUE (1)
FALSE FALSE FALSE (0)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy