Cc101 Reviewer For Midterms

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

CHAPTER 1: PROGRAMMING CONCEPTS

Computers are just machines which will not do anything unless the task are specified by the
users’ using programs that are executed into them.
Software/computer program is a collection of codes that instructs the computer on all the
processes that it must perform. Hardware is the physical components of a computer.
Program codes is the lists of instructions. Program coding/coding is the process of typing codes
into a computer. Programmers are the people who writes the program codes.
1. System Programmers
- People who create and maintain programs which are involved in the computer’s
basic operating functions like operating systems, utilities, and device drivers.
2. Application Programmers
- Ones who create and maintain programs that have specific functions such as Point of
Sale (POS) programs that calculate and generate the payroll report of a certain
company and others.
Steps in Programming
1. Planning
- Revolves around the determination of requirements, then setting the processes by
which goals are to be achieved.
2. Analysis
- Determine the precise objectives that you want to achieve to create a solution to the
presented problem. Output is the file generated/processed. File is a collection of
information. Input is the data that the program requires to produce the desired
result. Process is a mechanism for converting input to output.
3. Design
- We use this analysis to design a solution. Use modeling tools to guide you in
designing a solution to the problem such as flowcharts and algorithms.
4. Development
- Translate the design into a program.
5. Testing and Debugging
- Testing the problem’s solution on the computer overlaps with the design and
development phases. Bugs are computer errors and Debugging is the process of
correcting errors.
Documentation
- Means that you must create materials that will generally describe all the things you
did in the whole process of developing a project or a program.
Elements of Programming
1. Input
- Necessary information is collected at the start of programming.
2. Data
- This is the input/Raw value since nothing has been done to them.
3. Operations
- The data are then applied with the correct operations to manipulate it. The process.
4. Output
- The manipulated data will be extracted from the program and sent back to the user.
5. Conditional Execution/Branching
- Data can also be manipulated using this. There may be codes that require
comparison first before execution. Line by line execution.
6. Loops
- Looping/execute a set of instructions until the condition inside the loop statement
evaluates to false.
7. Subroutines
- Breaking data into small pieces and is executed at different locations in the program.
Programming Paradigms/Styles of programming
1. Procedural
- Running the codes line by line without skipping any of the statements.
2. Modular
- Turning a huge program into small ones with simpler codes.
3. Data Abstraction
- Hiding the attributes of the data making it appear more compound than more
primitive.
4. Object-Oriented Programming
- Represents concepts as “objects” that have specific attributes and methods.
CHAPTER 2: NUMBER SYSTEMS
Number system is a way how to represent numbers.
Digits are one symbols that represents a number. The number 143 consists of 3 digits, 1, 4 and
3.
Weight is the value of each digit position.
Decimal weight represents the value of each digit position of a decimal number such as UNITS
(100), TENS (101), HUNDREDS (102), THOUSANDS (103), etc.
Binary weights are enumerated as UNITS (20), TWOS (21), FOURS (22), EIGHTS (23), and so on.
Hexadecimal weights are enumerated as UNITS (160), SIXTEENS (161), and so on.
Decimal Number System - 10 digits/base (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9)
Binary Number System – 2 digits/base (0 and 1)
Hexadecimal Number System – 16 digits/base (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F)

1. BINARY NUMBER TO DECIMAL NUMBER CONVERSION


STEPS:
a. Write the Binary number downwards.
b. Multiply each digit with the corresponding binary weights starting with UNITS from
the bottom.
c. Add the products. The sum is the corresponding decimal number.

2. DECIMAL NUMBER TO BINARY NUMBER CONVERSION


STEPS:
a. Write the given decimal number and divide it by 2.
b. Write the quotient and the remainder.
c. Divide the quotient by 2.
d. Repeat steps b and c until the quotient is 0.
e. Write the digits from bottom to top. The resulting string will be the binary number.
3. HEXADECIMAL NUMBER TO BINARY NUMBER CONVERSION
To convert Hexadecimal number to Binary, the TABLE OF EQUIVALENCES should be
used.

- Remember: 8,4,2,1 for the 0s and


1s

a. Write the digits of the hexadecimal number separately.


b. Using the Table of Equivalences, write the corresponding binary equivalent under
each digit.
c. Cross-out the unnecessary zeroes. The UNNECESSARY ZEROES can be found at the
leftmost digit.
d. Write the binary digits as a string.

4. BINARY NUMBER TO HEXADECIMAL NUMBER CONVERSION

STEPS:

a. Group the digits of the binary number from the last digit by 4’s.

b. If the last group is less than 4 digits, add zeros to the left to make it 4. Ex. 11, add 2 zeroes to
make it 0011. All the groups should have 4 digits.

c. From the Table of Equivalences, write below the corresponding hexadecimal number
equivalent of each group.

d. Write the hexadecimal digits as a string.

5. HEXADECIMAL NUMBER TO DECIMAL NUMBER CONVERSION


STEPS:
a. Write the hexadecimal number downwards. If the hexadecimal digit is a letter, change it first
to its corresponding decimal number.
b. Multiply each digit with the corresponding hexadecimal weights starting with UNITS at the
bottom of the list.
c. Add the products. The sum is the corresponding decimal number.
6. DECIMAL NUMBER TO HEXADECIMAL NUMBER CONVERSION
STEPS:
a. Divide the hexadecimal number by 16.
b. Write the quotient and the remainder.
c. Divide the quotient by 16.
d. Repeat steps b and c until the quotient is 0.
e. Write the digits from bottom to top. The resulting string will be the binary.

CHAPTER 2: PROGRAMMING LANGUAGES


History of Programming Languages
1. Machine Language
- First computer programming language. It is written with binary digits, that is, 0s and
1s.
- Machine language is the sole programming language which is recognized by the
computer and can only be written by low level programmers.
2. Assembly Language
- Slightly high-level language than the machine language.
- Uses mnemonics which are memory aids that are abbreviated alphabetic
instructions.
- Assembler is used to convert codes written in assembly language into machine
language.
3. High-level Language
- Program written in English words that even common people can understand.
Types of High-Level Programs
1. Procedure-oriented programs – The program is focused on its step-by-step process of
solving a given problem.
EX:
a. Common Business-Oriented Language (COBOL)
b. Pascal Language
c. C Language
d. Beginner’s All-purpose Symbolic Instruction Code (BASIC)
e. C++, Visual Basic, Java

2. Object-oriented programs – Focuses on transforming real-like objects into its digital


representation.
EX: C++ Visual Basic Java
Control Structures/Logic Structures
- Are statements which oversee the flow on how a program is executed.
1. Sequence Structure – Line of the program are executed in a procedural method.
2. Selection Structure/Decision Structure – Execution of a statement or a block of a
statements will be dependent on outcome of comparing the values in an expression.
3. Repetition Structure/Looping – The statement or block of statements are done again
and again until the result of the comparison expression becomes “false”.
Flowchart
- Is a guide in creating programs that uses symbols.
- This uses an Off-Page Connector. It is shaped like an inverted house.
- You can skip the whole planning process of the design and only put the output as the
answer since the design will be made on the sample output.

CHAPTER 4: C++ PROGRAMMING


# Hash
<> Angle brackets
; Semicolon
() Open & Close parenthesis
{ Opening brace
} Closing brace
<< Insertion operator
“” Quotation/Double quotation
_ Underscore
>> Extraction operator
= Assignment operator
\ Slash
/ Backslash
CHAPTER 5: IDENTIFIERS, VARIABLES AND CONSTANTS
Identifiers are names given to variables and constants. C++ is case sensitive.
1. Can be letters, numbers, and underscore but no other symbols can be used.
2. Can’t start with numbers.
3. Can’t be named after reserved words.

EXAMPLES OF VALID IDENTIFIERS:


Age redRibbon year123 ako_ikaw_tayo ARVEE

Conventionality for identifiers:


Variables – Small letters/lowercase EX: two, cat, number1
If a variable name you want to use is consisted of two or more words, use small letters to the
first word then capitalize the first letter/s of the succeeding word/s. The variable will appear
like it has humps thus, it is said to be using camel case format.
Examples:
interestRate numberOfHoursWorked taxRate

Constant – Capital letters EX: TWO, CAT


Data types

Mas madalasan na ginagamit double dahil mas precise or accurate and lilitaw na sagot kesa sa
float. "Float should only be in cases when we're dealing with small decimal values" Ginagamit
lng ang float if maliliit na decimals and ginagamit tulad ng 2.01, 1.50 at etc
Short has a memory size of 2 bytes, whereas int has a memory size of 4 bytes. Using short can
conserve memory than using int which can be important when using a large array. Use int
unless you conserving memory is critical, or your program uses a lot of memory (e.g., many
arrays). Long is a large range of whole numbers. – Same as double and float.
Variables
A variable’s value can be changed. The syntax for variable is ---
data_type variable_name;
int x;
float interest_rate;
char alias;

data_type variable_name = initial_value;


int numb1 = 10 ;
double rating = 7.53;
char x = ‘R’;
Constants
A const’s value CANNOT be changed. You can declare constants before the main method of a C+
+ program like this:
#define PI 3.1416
#define LETTER ‘a’
If you want to declare a constant inside the main method, use the following syntax:
const data_type CONSTANT_NAME = value;
const double PI = 3.1416;
const char LETTER = ‘a’;

Mathematical Operators

You might also like