You are on page 1of 14

COMPUTER PROGRAMMING

Programmer Program (Instructions) Computer

COMPUTER
- General purposes machine that performs computational tasks
- Can’t do anything on their own/ without instructions
- Executes the program
PROGRAM
- Step-by-step information to perform tasks
- Uses programming languages
PROGRAMMER
- The one who writes the program

Binary Language
- Uses 0 and 1 values
- Easier to create for the hardware level (1 = exists; 0 = doesn’t exists)
- Machine language

TYPES OF PROGRAMMING LANGUAGES

PROGRAMMING LANGUAGES
- A language that a computer understands

MACHINE LEVEL LANGUAGES


- Uses 0 and 1 values
- Directly working on the computer memory and data
ASSEMBLY LEVEL LANGUAGES
- Combination of 0 and 1 values and mnemonic/symbolic codes
- Cannot be directly executed in the computer

Assembly Language ASSEMBLER Machine Language


(source code)

HIGHER LEVEL LANGUAGES


- Easier to learn and very close to readable human languages
- Cannot be directly executed in the computer
- (JAVA, C#, Python, etc.)
-

Higher Level COMPILATION/INTERPRETATION Machine Level

MIDDLE LEVEL LANGUAGES


- Some type of high level languages that directly deals with computer memory and data.
- (C, C++, etc)

COMPILATION/INTERPRETATION

Higher Level COMPILER Machine Level


(converts the entire program)

Higher Level INTERPRETER Machine Level


(converts the program line-by-line)
C Data Types
- declarations for variables
- determines the type and size of data associated with variables

int (Integer)
- whole numbers that can have both zero, positive and negative values but no decimal
values
- size: usually 4 bytes (32 bits)
float and double
- used to hold real numbers (with decimals)
- float size: 4 bytes
- double size: 8 bytes

char
- used for declaring character type variables
- size: 1 byte

void
- "absent" , "nothing" , or "no type"

short and long


- used for declaring short and long specifiers.
- (ex. long double d; )

signed and unsigned


- type modifiers that alters the data storage of a data type
- (ex. unsigned int x;)

Other data types defined in C programming are:


- bool Type (ex. true or false)
- Enumerated type (ex. enum )
- Complex types (ex. float complex )
C Input Output (I/O)

scanf() function
- to take input from the user

printf() function
- a library function that displays output to the user

! - means “not” >= - greater than or equal


* - multiplication (gives product) <= - less than or equal
/ - division (gives quotient) == - equal to (two equal sign: same value)
% - modulo (gives remainder) = - assignment operator (one equal sign:
gives value to variables)
+ - addition (gives sum)
&& - AND operator (must satisfy both)
- - subtraction (gives difference) | | - OR operator (must satisfy at least one)
CONDITIONAL STATEMENTS

if...else Statement
(Process)
- If the result is true or the condition was satisfied: the if statement will be executed while
skipping the else statement.
- If the result is false or the condition was not satisfied: the else statement will be executed
and the if statement will be ignored.
(ex)
Other types of if…else Statements
- if...else Ladder
(ex.)

- Nested if...else
(to include an if...else statement inside the body of another if...else statement.)

NOTE: If the body of an if...else statement has only one statement, you do not need to use
brackets {}.
C Switch Statement
- an alternate to if-else-if ladder statement which allows us to execute multiple operations

(ex)

(ex2)
(Rules)
1) The switch expression must be of an integer or character type.
2) The case value must be an integer or character constant.
3) The case value can be used only inside the switch statement.
4) The break statement in switch case is optional.
ALGORITHM, PSEUDOCODE, AND FLOWCHART

Source code
- programming statements that are created by a programmer with a text editor or a visual
programming tool and then saved in a file.

(ex)

Algorithm
- Step-by-step process to solve a problem with the use of simple terms in the form of a
sentence/paragraph.
- Formal form (detailed)

(ex)
Pseudocode/ Pseudo Code
- Step-by-step process to solve a problem that uses technical terms.
- Informal form (not detailed)

(ex)

Flowchart
- Pictorial form of step-by-step process to solve a problem.
- Uses flowchart symbols/ algorithm vocabulary

(ex)
Flowchart Symbols/ Algorithm Vocabulary

(ex: with Decision Symbol)


(ex: with On-page Connector)

(ex: with Off-page Connector)

Page 1 Page 2

You might also like