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

Module 1 Page 1-12

This document describes an introductory course in computer programming. The course discusses logic formulation, C++ fundamentals, operators, control structures, work areas, and arrays. Students will learn algorithms, flowcharts, and pseudocode to develop program logic. They will complete hands-on activities using C++ to write, compile, and execute programs. The course aims to teach students programming concepts and skills.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views

Module 1 Page 1-12

This document describes an introductory course in computer programming. The course discusses logic formulation, C++ fundamentals, operators, control structures, work areas, and arrays. Students will learn algorithms, flowcharts, and pseudocode to develop program logic. They will complete hands-on activities using C++ to write, compile, and execute programs. The course aims to teach students programming concepts and skills.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Republic of the Philippines

RIZAL TECHNOLOGICAL UNIVERSITY


Cities of Mandaluyong and Pasig

COLLEGE OF ENGINEERING, ARCHITECTURE, AND TECHNOLOGY


Computer Department

CPE01: Fundamentals of
Computer and
Programming

This is an introductory course in computer programming topics. The


course discusses the Logic Formulation and Design; Fundamentals of C++,
Operators in C++; Control Structures; Work Areas; and Array and List. The
student will learn algorithms applicable to all programming languages and
use charts commonly used in business and information processing. Program
Logic will be developed using flowcharts and pseudocode. There will be
offline hands-on activities using C++, a high-level object-oriented computer
programming language to reinforce the learning of the students on the
fundamentals of computer programming, including how to write, compile,
and execute programs. Some familiarity with computers is beneficial.

Objectives
Upon completion of this course, students will be able to:

o Identify structures governing the design and implementation of modern


programming languages
o Describe how different programs are compiled and executed
o Differentiate the features of 1st, 2nd, 3rd, 4th, 5th, and 6th generation
programming languages
o Design and use simple algorithms using flow charts and pseudo-codes.
o Describe the features and rationale of Object-Oriented Programming
o Apply the standard computer program development cycle of
specification, design, implementation, testing/debugging, and
maintenance using a modern programming language.
o Use C# or Visual Basic programming language to implement simple
computer programs.
o Demonstrate competency in basic programming skills including use of
variables, constants, control structures, simple data types, input and
output management, and simple GUIs.
o Demonstrate the ability to appropriately document programming
code and conform to the recommended coding style/conventions.

DRJNA20 Page 1
Course Outline

 Module 1: Introduction to Programming, Logic Formulation, and Design


 Module 2: Fundamentals of C++
 Module 3: Operators in C++
 Module 4: Control Structures
 Module 5: Control Structures in C++
 Module 6: Work Areas
 Module 7: Array and List

DRJNA20 Page 2
Module 1. Introduction to Programming, Logic
Formulation, and Design

Welcome to the first module titled Introduction to Programming, Logic


Formulation, and Design! This module is designed to help you identify
structures governing the design and implementation of modern
programming languages; describe how different programs are compiled and
executed; differentiate the features of 1st, 2nd, 3rd, 4th, 5th, and 6th
generation programming languages; Identify important steps in the program
development cycle; and draw a flowchart to represent the program’s logic.
You should linearly proceed through the content below. Researching beyond
the coverage of this module is highly encouraged to supplement your
understanding of the topics covered. Always think, and see beyond the box.
Be sure to take notes as you go on anything that might be confusing - we will
go over any questions you may have on the material during the virtual class.

Competency Goal 1: The learner will conduct researches and use appropriate
technology to build an understanding of what is programming and how program
logic is formulated.

Objectives:

1. Identify structures governing the design and implementation of modern


programming languages
2. Define what is program logic formulation
3. Identify the different programming languages that can be used to create
simple programs.
4. Differentiate the features of 1st, 2nd, 3rd, 4th, 5th and 6th generation
programming languages
5. Differentiate between procedural programming and object-oriented
programming languages.
6. Use technology to searching beyond the coverage of this module to
supplement understanding of the topic covered.

Let us now start exploring the world of Computer Programming

DRJNA20 Page 3
Course Module

Introduction

What is programming?

Programming is the implementation of logic to facilitate specified computing


operations and functionality. It occurs in one or more languages, which differ by
application, domain, and programming model.

A computer program is a set of instructions that guide a computer to execute


a particular task. It is like a recipe for a cook in making a particular dish. The recipe
contains a list of ingredients called data or variables and a list of steps that guide the
computer what to do with the data. Therefore, programming is a way of giving
computer instructions about what they should do next. These instructions are known
as code, and computer programmers write code to solve problems or perform a
task.

Programming or coding is a language that is used by the operating systems


to perform the task. The computer understands binary languages with digits 1s and
0s which are difficult for humans to understand. So generally an intermediate
language is used instead of binary language. Programs use high-level language that
is interpreted into bytes that the computer understands. A programmer writes a
source code using a development environment and uses a tool called language
translator that interprets the instructions and allows the computer to read, translate,
and execute the program statements to perform a function.

Today there are different user-friendly and easily understandable languages


supporting different types of programming. Some of the famous computer
languages are FORTRAN, C, C++, PASCAL, BASIC, Java, C#, and many other high-
level languages. Further, an interpreted p-code or byte code is generated in some
advanced languages like Java and .NET.

These languages enable one to create and perform various kinds of


applications. However, in the whole process of programming, It is important to
understand that a program written in any of the high-level languages needs to be
converted into machine language to run on a computer. This conversion is done
with a compiler or an interpreter. In all kinds of programming languages a compiler
and, if required, an interpreter is available. The basic difference between the two is
that compilers convert the entire program into machine code while interpreters
convert one statement at a time to machine language before it turns out to be an
executable one.

The most important aspect of programming is to analyze and adopt specific


solutions while solving any problem. This needs a programming approach that
defines the modularity of the program one writes and how it is related to others in an
application. There are two different programming approaches: procedure-oriented

DRJNA20 Page 4
and object-oriented. The procedure-Oriented Programming (POP) approach
focuses on creating procedures or a block of code sequentially, keeping in mind to
accomplish a specific job. The key features of this kind of approach are the use of
procedures, sequencing of procedures, and sharing global data.

However, in the case of the Object-Oriented Programming (OOP) approach,


the focus is totally towards identifying and creating objects or data as well as
manipulating and interactions of objects. Unlike POP where a piece of code uses
data, in the OOP approach, the data uses a piece of reusable code to execute
tasks. Principal features of the objects, data encapsulation, abstraction, inheritance,
and polymorphism. This kind of approach provides a realistic representation,
simplicity, flexibility to change, and security of data. Today most of the high-level
programming languages are based on an object-oriented approach such as Java,
C#, C++, and Visual Basic.

What does Program Logic Formulation mean?

Probably, the best way to appreciate “Program Logic Formulation” is by first


knowing what “Logic” is. In Etymology “Logic” is a method of human thought that
involves correct thinking in a linear, step by step manner about how a problem can
be solved. Hence, the important elements must conform to define logic and that is
the correct thinking or reasoning of the person. If any of the elements would be
missing, then no logic can be derived. Logic is the systematic study of reasoning that
provides standards by which valid reasoning can be recognized.

The importance of logic in computer science is not as complicated as one


might think of it philosophically. Its uses in programming are only to bring your
instructions into proper order. Other than that, no further deductions or inference is
needed. In writing instructions for the computer you have to take the individual steps
comprising of the whole act to attain the desired results. The computer doesn’t
possess the inherent power of thinking as a human would demonstrate in the
conduct of his task. Thus, each step must be taken and arranged according to the
order of their priorities. These individual steps will make the instructions needed by
the computer to execute its task. Each step is known as an algorithm.

Let us consider the process of “Mixing a Juice” to further illustrate the concept
of the logic formulation. When you want to make a juice there are certain steps you
need to do and so you can sip it in the end. Even we, humans, cannot take all the
steps at one time just to make a glass of juice, much so if a computer is to make it for
you. Computers work faster than human but despite that tremendous speed,
computers will still take your instructions one at a time. So what are the steps in
preparing a glass of juice? Consider the following steps:

1. Get a glass
2. Put a spoonful of powder juice into the glass
3. Pour cold water into the glass
4. Sir it with a spoon
5. Put an ice cube
6. Put a drinking straw
7. Sip through a straw

DRJNA20 Page 5
The above steps are arranged in a logical order. Steps 2 to 6 can be done
interchangeably without affecting the logical process except for steps 1 and 7.
Logic formulation simply means bringing the steps as required by the task in Proper
Order so that when it is executed procedurally the desired result is achieved
according to the required output specifications. Therefore, Programming Logic
Formulation is the process of coming up with the appropriate methodology in
developing a specific program logic that will perform a prescribed computing task
or solve a problem using the computer. Programming Logic Formulation is the
process of coming out with the basic steps to implement a procedure in computer
programming. This is usually resorted to when having a top-down design. Flowcharts
and pseudo-codes are two of the most common output of the exercise.

Program Design and programming Languages

Computer software is a set of programming instructions, before starting


coding, programmers must understand the user requirements and the flow of logic
of the program.

Software developers can use the Program Development Life Cycle (PDLC) to
define the program structure. The six phases of PDLC are defining the problem,
designing the program, coding the program, testing and debugging the program,
formalizing the solution, and maintaining the program.

Program Designing begins with deciding the output and framing the program
logic. The design is then broken down into modules to facilitate programming. All
computer languages have a vocabulary of their own. If a programmer does not
strictly follow the syntax of a programming language, the computer will not
understand the commands given in the program.

Programming Languages generally fall into two categories and these are the
low-level languages and high-level languages. First-generation languages and
second-generation languages are regarded as low-level languages, whereas the
languages of higher generations are regarded as high-level languages.

Machine languages and Assembly languages are low-level languages and


considered hardware friendly. Machine language also referred to as machine code
or objects code, consists of binary digits or bits (0s and 1s) that the computer reads
and interprets, and which respond directly to the ON and OFF electrical pulses
generated by the computer. The exact machine language for a program or action
can differ from the operating system. The specific operating system dictates how a
compiler writes a program or action into machine language (See machine
language examples below). Assembly language sometimes referred to as assembly
or ASM is easier to use than machine language as a programmer can use symbols,
to sum up, program instructions. It is called a low-level programming
language because there's (nearly) a one-to-one relationship between what it tells
the computer to do, and what the computer does. In general, one line of an
assembly program contains a maximum of one instruction for the computer.
Programs written in assembly languages are compiled by an assembler. Every
assembler has its assembly language, which is designed for one specific
computer architecture (See assembly language examples below).

DRJNA20 Page 6
Machine language example

An example of machine language


(binary) for the text “Hello World.” An example of machine language (non-
binary), which prints the letter “A” 1000 times
to the computer screen.
01001000 01100101 01101100 169 1 160 0 153 0 128 153 0 129
01101100 01101111 00100000 153 130 153 0 131 200 208 241
01010111 01101111 01110010 96
01101100 01100100

Assembly language example

A "Hello, World" written for a 64-bit Intel processor. This can be compiled and run on
64-bit Linux.

extern printf ; the C printf function, to be called


section .data ; Data section, initialized variables
msg: db "Hello, world!", 0 ; C string terminates with 0
fmt: db "%s", 10, 0 ; The printf format, "\n",'0'
section .text ; Begin code section
global main ; the standard gcc entry point
main: ; the program label for the entry point
push rbp ; set up stack frame, must be aligned
mov rdi,fmt
mov rsi,msg
mov rax,0 ; can also be: xor rax,rax
call printf ; Call C printf function
pop rbp ; restore stack
mov rax,0 ; normal, no error, return value
ret ; return

DRJNA20 Page 7
Likewise, a high-level language doesn’t require the programmer to know the
details of a processor, but they still require programmers to specify the procedure to
be followed to solve a problem. High-level languages provide abstractions of low-
level operations which allow the programmer to focus more on describing what they
want to do and less on how it should be done. Programming this way is more
convenient and makes programs easier to read at the sacrifice of low-level control.
Programs are written in high-level languages never match the raw speed and
efficiency of programs written in assembly.

Third-generation language also known as a "3GL," refers to a high-level


programming language such as FORTRAN, COBOL, BASIC, Pascal, and C. It is a step
above assembly language and a step below a fourth-generation language (4GL).

The Fourth-generation Languages (4GL) were identified as "non-procedural"


or "program-generating" languages, contrasted with 3GLs being algorithmic or
procedural languages. These are closer to human language than other high-level
languages and are accessible to people without formal training as programmers.
They allow multiple common operations to be performed with a single programmer-
entered command. They are intended to be easier for users
than machine languages (first-generation), assembly languages (second-
generation), and older high-level languages (third-generation). 4GL free
programmers from worrying about the procedures to be followed to solve a
problem, as it originally defined found uses focused on accessing databases,
reports, and websites. An application generator facilitates the development of
applications. It includes defining input transactions, editing such transactions,
creating a database, updating files, generating reports, and processing queries.
Some advanced 3GLs like Python, Ruby, and Perl combine some 4GL abilities within
a general-purpose 3GL environment, and libraries with 4GL-like features have been
developed as add-ons for most popular 3GLs, producing languages that are a mix
of 3GL and 4GL, blurring the distinction.

The fifth-generation programming languages are designed to enable the


computer to solve a problem. These languages incorporate concepts like artificial
intelligence, expert systems, etc. language translators convert source code into
object code. The two types of translators are Compilers and Interpreters. A compiler
is a translation program that translates the entire source code of a high-level
programming language into object code and creates an object file. An interpreter
is a program that executes the instructions which are written in a high-level
language. OPS5 and Mercury are examples of fifth-generation languages as is ICAD,
which was built upon Lisp. KL-ONE is an example of a related idea, a frame
language.

Different types of programming languages serve different purposes. Some of


the programming languages which are popularly used include COBOL, BASIC,
PASCAL, C, Ada, C++, Visual Basic, and Java.

Procedural Programming can be defined as a programming model which is


derived from structured programming, based upon the concept of calling
procedure. Procedures, also known as routines, subroutines or functions, simply
consist of a series of computational steps to be carried out. During a program’s
execution, any given procedure might be called at any point, including by other

DRJNA20 Page 8
procedures or it. Languages used in Procedural Programming are FORTRAN, ALGOL,
COBOL, BASIC, Pascal, and C.

Object-Oriented Programming (OOP) can be defined as a programming


technique designed to provide component reusability. The basic concepts of
object-oriented programming are objects and classes, abstraction, encapsulation,
polymorphism, and inheritance. Objects contain data in the form of attributes and
code in the form of methods. In object-oriented programming, computer programs
are designed using the concept of objects that interact with the real world. OOP
languages are various but the most popular ones are class-based, meaning that
objects are instances of classes, which also determine their types. Languages used in
Object-Oriented Programming are Java, C++, C#, Python, PHP, JavaScript, Ruby,
Perl, Objective-C, Dart, Swift, Scala.

To give you more details on how Procedural and Object-Oriented


Programming differ from one another, see table 1 below:

Table 1: Difference between Procedural Programming and Object-Oriented Programming

PROCEDURAL ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING


In procedural programming, the In object-oriented programming, the
program is divided into small parts program is divided into small parts
called functions. called objects.
Procedural programming follows a top- Object-oriented programming follows a
down approach. bottom-up approach.
There is no access specifier in procedural Object-oriented programming has
programming. access specifiers like private, public,
protected, etc.
Adding new data and functions is not Adding new data and functions is easy.
easy.
Procedural programming does not have Object-oriented programming provides
any proper way of hiding data so it is less data hiding so it is more secure.
secure.
In procedural programming, overloading Overloading is possible in object-
is not possible. oriented programming.
In procedural programming, a function is In object-oriented programming, data is
more important than data. more important than function.
Procedural programming is based on the Object-oriented programming is based
unreal world. on the real world.
Examples: C, FORTRAN, Pascal, Basic, Examples: C++, Java, Python, C#, etc.
etc.

Programming language semantics and syntax are used when constructing an


application. Thus, programming requires knowledge of application domains,
algorithms, and programming language expertise.

Programming language logic differs by the developer. From a high-level


good code can be evaluated with factors such as:

DRJNA20 Page 9
1. Robustness: Focuses on program continuation capability, regardless of errors
or incorrect data.
2. Reliability: focuses on the correct design and algorithm implementation.
3. Efficiency: focuses on memory, hardware, or other properties used to optimize
programs.
4. Readability: proper documentation and indentation availability, which
provides insight into other program developers or designers.

Let’s test your learning by answering our first quiz. Good luck!

DRJNA20 Page 10
Quiz #1.1
Good Luck!
Assessment

“Any fool can write code that a computer can understand. Good programmers
write code that humans can understand.” – Martin Fowler

Name: ____________________________________ Year Level: _____________

Section: ___________________________________ Date: ____________________

Multiple Choices

Direction: This is a 10-item quiz. Read each statement carefully and choose the
correct answer from the given options below.

1. It is an electronic device capable of performing complex computations in a short


time
a. Application
b. Computer
c. Operating System
d. Software

2. It is an 8-bit character encoding (code page) used on IBM mainframe operating


systems.
a. ASCII
b. UNICODE
c. EBCDIC
d. UNIX

3. These are computer programs used to accomplish a specific or specialized task


for computer users such as creating and editing documents, making a graphic
presentation, or listening to music.
a. Operating System
b. Office Application
c. Application Software
d. System Software

4. It is a methodology that is typically used to develop, maintain, and replace


information systems for improving the quality of the software design and
development process.
a. Computer Architecture Development Cycle
b. Program Life Cycle
c. System Life Cycle
d. Software Development Life Cycle

DRJNA20 Page 11
5. Which of the following is best to consider during program development?
a. software requirements specify what the task is that the program must perform
b. software requirements specify how the program will accomplish the task
c. software requirements specify how to test the program when it is done
d. software requirements specify how to divide the task into subtasks

6. Which of the following is the process of finding errors and fixing them within a
program?
a. Debugging
b. Compiling
c. Executing
d. Coding

7. A list of instructions that enable a computer to perform a specific task is a


__________
a. Algorithm
b. Binary Code
c. Machine Code
d. Computer Program

8. List are the three (3) types of language translators except __________.
a. Syntax
b. Compiler
c. Assembler
d. Interpreter

9. Determine the sets of words representing a computer system.


a. Input --> Process --> Output
b. Input --> Output --> Process
c. Output --> Process --> Input
d. Process --> Input --> Output

10. Select the types of the algorithm used in representing problem-solving


graphically.
a. IPO
b. Flowchart
c. Algorithm
d. Pseudo Code

DRJNA20 Page 12
References:

https://www.yourdictionary.com/programming

http://www.scribd.com/doc/7368548/Logic-Formulation

http://au.answers.yahoo.com/question/index?qid=20071110191353AABcdvH

http://wiki.answers.com/Q/What_are_the_logic_formulation

https://www.computerhope.com/jargon/m/machlang.htm#:~:text=Machine%20lan
guage%20example,the%20text%20%22Hello%20World.%22&text=Below%20is%20anot
her%20example%20of,times%20to%20the%20computer%20screen.

https://www.computerhope.com/jargon/a/al.htm#:~:text=Programs%20written%20i
n%20high%2Dlevel,JavaScript%2C%20Clojure%2C%20and%20Lisp.

https://www.britannica.com/technology/fourth-generation-language

https://www.geeksforgeeks.org/differences-between-procedural-and-object-
oriented-programming/

https://www.geeksforgeeks.org/how-to-write-a-pseudo-code/

https://www.computertaleem.com/problem-
analysis/#:~:text=changes%20before%20completion.-
,Problem%20Analysis%20in%20Computer%20programming%20is%20the%20process%2
0where%20we,discussed%20for%20giving%20the%20solution.

https://pediaa.com/what-is-the-difference-between-system-flowchart-and-
program-
flowchart/#:~:text=The%20main%20difference%20between%20system,flowchart%20r
epresents%20a%20single%20program.&text=One%20such%20diagram%20is%20a,mo
del%20to%20a%20given%20problem.

DRJNA20 Page 13
DRJNA20 Page 14

You might also like