Computer Programming Engr - Mojares SmartEDGE Unlocked

Download as pdf or txt
Download as pdf or txt
You are on page 1of 120

BY: ENGR.

JACOB “COB”
MOJARES
TOPIC COMPUTER PROGRAMMING

What is computer programming?


Q 01 The rules to any programming language are its

A. syntax
B. interpretation
C. logic
D. customs

A. syntax
COMPUTER PROGRAMMING
Q 02 The step-by-step instructions that solve a problem
are called

A. an algorithm
B. a list
C. a plan
D. a sequential structure

A. an algorithm
COMPUTER PROGRAMMING
Q 03 Typing the function's name as Main, rather than
main, is an example of

A. an entry error
B. a function error
C. a logic error
D. a syntax error

D. a syntax error
COMPUTER PROGRAMMING
Q 04 refers to the process of locating and removing
the errors in a program

A. Analyzing
B. Correcting
C. Debugging
D. Executing

C. Debugging
COMPUTER PROGRAMMING
Q 05 The process of drawing a flowchart for an algorithm
is called

A. Performance
B. Evaluation
C. Algorithmic Representation
D. Flowcharting

D. Flowcharting
COMPUTER PROGRAMMING
TOPIC FLOWCHART

FLOWCHART
TOPIC FLOWCHART SYMBOLS
FLOWCHART
FLOWCHART ALGORITHM

STEP 1: START, LEAVE HOME

STEP 2: CHECK TIME

STEP 3: IS IT 7 AM?
IF YES, TAKE BUS
IF NO, TAKE SUBWAY

STEP 4: END, REACH SCHOOL


Q 06 The loop condition in a flowchart is represented by
a(n)

A. Diamond
B. Oval
C. Parallelogram
D. Rectangle

A. Diamond
COMPUTER PROGRAMMING
Q 07 Actual instructions in flowcharting are represented in

A. Circles
B. Boxes
C. Arrows
D. Lines

B. Boxes
COMPUTER PROGRAMMING
Q 08 Which of the following flowchart symbols represents
the if selection structure?

A. Diamond
B. Hexagon
C. Oval
D. Parallelogram

A. Diamond
COMPUTER PROGRAMMING
Q 09 A detailed flowchart is called

A. Stack
B. Macro
C. Micro
D. Union

C. Micro
COMPUTER PROGRAMMING
TOPIC PROGRAMMING CONTROL STRUCTURE

PROGRAMMING CONTROL STRUCTURE


TOPIC PROGRAMMING CONTROL STRUCTURES
Q 10 Which of the following is not a programming control
structure?

A. Repetition
B. Selection
C. Sequence
D. Sorting

D. Sorting
COMPUTER PROGRAMMING
Q 11 The set of instructions for how to tie a bow is an
example of the structure.

A. Control
B. Repetition
C. Selection
D. Sequence

D. Sequence
COMPUTER PROGRAMMING
Q 12 The instruction "If it's raining outside, then take an
umbrella to work" is an example of the
structure.

A. Control
B. Repetition
C. Selection
D. Sequence

C. Selection
COMPUTER PROGRAMMING
TOPIC LOW-LEVEL & HIGH LEVEL PROGRAMMING

LOW-LEVEL & HIGH LEVEL PROGRAMMING


TOPIC LOW-LEVEL & HIGH LEVEL PROGRAMMING

HIGH-LEVEL LANGUAGE

ASSEMBLY LANGUAGE

MACHINE LANGUAGE

HARDWARE
Q 13 A language which is close to that used within the
computer is

A. High-level language
B. Assembly language
C. Low-level language
D. All of the above

C. Low-level language
COMPUTER PROGRAMMING
Q 14 A notation used to express clearly on algorithm is
known as

A. Algorithmic language
B. Assembly language
C. Machine language
D. High level language

A. Algorithmic language
COMPUTER PROGRAMMING
Q 15 Which of the following isn’t a
characteristic of High level languages?

A. machine code
B. platform independent
C. interactive execution
D. user-friendly

A. machine code
COMPUTER PROGRAMMING
Q 16 Which of the following is the common abbreviation
for Assembly Language?

A. ASS
B. ASB
C. ASM
D. ASY

C. ASM
COMPUTER PROGRAMMING
TOPIC PROGRAMMING LANGUAGE FUNDAMENTALS

PROGRAMMING LANGUAGE FUNDAMENTALS


TOPIC Programming Language Fundamentals

DECLARE integer num


DECLARE STRING name = "John"
VARIABLE int age

DECLARATION float height


boolean isStudent
num1 = 4
num2 = “4”
TOPIC Programming Language Fundamentals
DATA TYPES
INTEGER (INT) FLOAT / DOUBLE BOOLEAN (BOOL)
1, 10, -2, -25 1.9999, π , e TRUE, FALSE, 1, 0

CHARACTER (CHAR) STRING (STR)


‘I’, ’L’, ’u’, ’s’, ’m’, ’!’, ‘1’ "smart edge", "Top 1"
TOPIC Programming Language Fundamentals
DATA TYPES
LIST ARRAY
numbers = [1, 2, 3, 4, 5] A = [1, 2, 3; 4, 5, 6; 7, 8, 9];
names = ["Amy", "Bob", "Joy"] B = [9, 8, 7; 6, 5, 4; 3, 2, 1];
Q 17 A fundamental type such as int or double is a

A. programmer-defined type
B. complex type
C. nonscalar type
D. scalar type

D. scalar type
COMPUTER PROGRAMMING
Q 18 The number 5.5e3 is a constant

A. character literal
B. named literal
C. numeric literal
D. string literal

C. numeric literal
COMPUTER PROGRAMMING
Q 19 Which of the following is(are) invalid string
constant(s)?

A. '7.15 pm'
B. "i like e"
C. "7.3el2"
D. "1234el2"

A. '7.15 pm'
COMPUTER PROGRAMMING
Q 20 The most efficient data type for a variable that stores
the letter C is the data type

A. Character
B. Double
C. Float
D. Long Integer

A. Character
COMPUTER PROGRAMMING
Q 21 The String data type is an extension of the
data type

A. Character
B. Double
C. Letter
D. Long

A. Character
COMPUTER PROGRAMMING
Q 22 You typically initialize a String variable to

A. an asterisk
B. a space enclosed in single quotes
C. the number 0
D. a zero-length string

D. a zero-length string
COMPUTER PROGRAMMING
Q 23 The first element in a string is

A. the name of the string


B. the first character in the string
C. the length of the string
D. the name of the array holding the string

B. the first character in the string


COMPUTER PROGRAMMING
Q 24 The element of an array is

A. the name of the array


B. a member of an array
C. a value assigned to an array
D. All of the above

B. a member of an array
COMPUTER PROGRAMMING
Q 25 An array element is accessed using

A. a first-in-first-out approach
B. the dot operator
C. a member name
D. an index number

D. an index number
COMPUTER PROGRAMMING
TOPIC BASIC OPERATIONS

ARITHMETIC OPERATORS
OPERATOR NAME
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
** Exponentiation
// Floor Division
TOPIC BASIC OPERATIONS

LOGICAL OPERATORS
OPERATOR NAME
&& AND
|| OR
! NOT
TOPIC BASIC OPERATIONS
COMPARISON OPERATORS
OPERATOR NAME
== EQUAL
!= NOT EQUAL
> GREATER THAN
< LESS THAN
>= GREATER THAN OR EQUAL TO
<= LESS THAN OR EQUAL TO
TOPIC BASIC OPERATIONS

ASSIGNMENT OPERATORS
OPERATOR
=
++
--
+=
-=
Q 26 An expression contains relational, assignment and
arithmetic operators. In the absence of parentheses,
the order of evaluation will be

A. assignment, relational, arithmetic


B. arithmetic, relational, assignment
C. relational, arithmetic, assignment
D. assignment, arithmetic, relational

B. arithmetic, relational, assignment


COMPUTER PROGRAMMING
Q 27 The two operators && an || are

A. arithmetic operators
B. equality operators
C. logical operators
D. relational operators

C. logical operators
COMPUTER PROGRAMMING
Q 28 The following statement where T is true and F is false
T&&T||F&&T

A. is true
B. is false
C. is wrong
D. not applicable in C language

A. is true
COMPUTER PROGRAMMING
Q 29 Evaluate the following expression:
3>6&&7>4

A. True
B. False
C. Invalid
D. Can't determine

B. False
COMPUTER PROGRAMMING
Q 30 Evaluate the following expression:
4>6||10<2*6

A. True
B. False
C. Invalid
D. Can't determine

A. True
COMPUTER PROGRAMMING
Q 31 Evaluate the following expression:
7>=3+4||6<4&&2<5

A. True
B. False
C. Invalid
D. Can't determine

A. True
COMPUTER PROGRAMMING
Q 32 The statement double total = 0.0; performs

A. assignment
B. initialization
C. rationalization
D. polymorphism

B. initialization
COMPUTER PROGRAMMING
Q 33 Which of the following assigns the number 5 to the
area variable?

A. area 1 = 5
B. area = 5
C. area == 5
D. area --> 5

B. area = 5
COMPUTER PROGRAMMING
TOPIC Programming Language Fundamentals

If (condition)then
do (instructions)
CONDITIONAL else if (condition 2) then
do (instructions)
BASIC IF-ELSE
else
do (instructions)
endif
TOPIC Programming Language Fundamentals

If (condition)then
do (instructions)
else
if (condition) then
CONDITIONAL do (instructions)
NESTED IF-ELSE else if (condition) then
do (instructions)
else
(instructions)
endif
endif
TOPIC Programming Language Fundamentals

switch choice
case choice1:
do (instructions)
break
case choice2:
SWITCH CASE do (instructions)
break
case choice2:
do (instructions)
break
default:
do (instructions)
end switch
TOPIC Programming Language Fundamentals

while (condition == True) then


WHILE LOOP do (instructions)
update (parameters)
end while
Q 34 The while loop is referred to as a(n) loop
because the loop condition is tested at the beginning
of the loop

A. Beginning
B. Initial
C. Pretest
D. Priming

C. Pretest
COMPUTER PROGRAMMING
TOPIC Programming Language Fundamentals
TOPIC Programming Language Fundamentals

for (counter) from (start) to (end)


do (instructions)
FOR LOOP update (counter)
end for
TOPIC Programming Language Fundamentals

function functionName(parameters)
do (instructions)
FUNCTIONS return value
end function
Q 35 The two parts of a function are the

A. header and footer


B. declarations and statements
C. legs and feet
D. header and body

D. header and body


COMPUTER PROGRAMMING
Q 36 The set of instructions for how to tie a bow is an
example of the structure.

A. Control
B. Repetition
C. Selection
D. Sequence

D. Sequence
COMPUTER PROGRAMMING
TOPIC TRANSLATORS

TRANSLATORS
TOPIC COMPILER VS INTERPRETER VS. ASSEMBLER

HIGH-LEVEL HIGH-LEVEL
LANGUAGE LANGUAGE COMPUTER
(HLL) (HLL) INSTRUCTIONS

COMPILER INTERPRETER ASSEMBLER

ASSEMBLY
LOWER BINARY

BINARY
LEVEL (0’s & 1’s)
LLL

LANGUAGE
(LLL)
TOPIC COMPILER VS INTERPRETER VS. ASSEMBLER

COMPILER INTERPRETER ASSEMBLER

integer num = 1 integer num = 1 movq %rsp,%rbp


TOPIC COMPILER VS INTERPRETER VS. ASSEMBLER
Q 37 A compiler means

A. A person who compiles source programs


B. The same thing as a programmer
C. Keypunch operator
D. A program which translates source program into
object program

D. A program which translates source program into object program


COMPUTER PROGRAMMING
Q 38 is a program that converts high-level
language to assembly language.

A. assembler
B. compiler
C. interpreter
D. linker

B. compiler
COMPUTER PROGRAMMING
Q 39 The output of an assembler is called?

A. data file
B. task file
C. object file
D. program file

C. object file
COMPUTER PROGRAMMING
Q 40 If an error occurs, what interpreter do?

A. terminate program
B. stops execution
C. reads the whole program even if it encounters
errors
D. give warning

B. stops execution
COMPUTER PROGRAMMING
Q 41 If an error occurs, what compiler do?

A. terminate program
B. stops execution
C. reads the whole program even if it encounters
errors
D. give warning

C. reads the whole program even if it encounters errors


COMPUTER PROGRAMMING
Q 42 A program that can execute high-level language
programs.

A. Compiler
B. Interpreter
C. Sensor
D. Circuitry

B. Interpreter
COMPUTER PROGRAMMING
TOPIC OBJECT-ORIENTED PROGRAMMING (OOP)

OBJECT-ORIENTED PROGRAMMING (OOP)


TOPIC OBJECT-ORIENTED PROGRAMMING (OOP)

(POP) (OOP)
PROCEDURAL OBJECT-ORIENTED
PROGRAMMING PROGRAMMING
TOPIC CLASS AND OBJECT
A class is like a blueprint, while an object is an instance of
that blueprint.
TOPIC CLASS AND OBJECT
A class is like a blueprint, while an object is an instance of
that blueprint.
name()
age()
ATTRIBUTES gender()
occupation()

walk()
eat()
PERSON FUNCTIONALITY
sleep()
(CLASS) work()
TOPIC OBJECT-ORIENTED PROGRAMMING (OOP)

Object Oriented Programming (OOP) is a type of


computer programming (software design) in which
programmers define the data type of a data
structure, and the types of operations (functions)
that can be applied to the data structure.

It is an approach to problem solving where all


computations are carried out using objects.
TOPIC THE FOUR (4) OOP CONCEPTS

ENCAPSULATION ABSTRACTION

INHERITANCE POLYMORPHISM
TOPIC THE FOUR (4) OOP CONCEPTS

ENCAPSULATION

- involves hiding both data and functionality within


a class, preventing external classes or code from
accessing them directly.

- it enables the concealment of implementation


details, fostering a code structure that is cleaner
and more organized.
TOPIC THE FOUR (4) OOP CONCEPTS

ABSTRACTION

- the process of simplifying complex systems by


breaking them down into smaller, more
manageable parts.

- it simplifies the intricacy of real-world entities,


facilitating developers in understanding and
utilizing objects more easily.
TOPIC THE FOUR (4) OOP CONCEPTS

INHERITANCE

- it is the process by which a class can inherit


properties and behaviors from a parent class.

- it facilitates code reuse by allowing the new class


to utilize the functionalities of the existing class,
thus avoiding redundancy.
TOPIC THE FOUR (4) OOP CONCEPTS

INHERITANCE
TOPIC THE FOUR (4) OOP CONCEPTS

INHERITANCE
TOPIC THE FOUR (4) OOP CONCEPTS

POLYMORPHISM

- it is the ability of an object to exhibit varying


behaviors depending on the context in which it is
utilized.

- it enhances flexibility by enabling the use of a


single interface for different object types,
simplifying code implementation and maintenance
Q 43 To be called object-oriented, a programming
language must allow

A. functions that return only a single value


B. #include files
C. inheritance
D. All of the above

C. inheritance
COMPUTER PROGRAMMING
Q 44 Inheritance is the principle that

A. classes with the same name must be derived from one


another
B. knowledge of a general category can be applied to more
specific objects
C. C++ functions may be used only if they have logical
predecessors
D. one function name may invoke different methods

B. knowledge of a general category can be applied to more specific objects


COMPUTER PROGRAMMING
Q 45 An object is

A. a category of classes
B. a name given to a class
C. an instance of a class
D. the same as a class

C. an instance of a class
COMPUTER PROGRAMMING
Q 46 Object is to class as

A. library is to book
B. mother is to daughter
C. Plato is to philosopher
D. president is to Lincoln

C. Plato is to philosopher
COMPUTER PROGRAMMING
Q 47 A pattern for creating an object is called a(n)

A. class
B. attributes
C. Private
D. public

A. class
COMPUTER PROGRAMMING
Q 48 Which of the following type of class allows only one
object of it to be created?

A. Virtual class
B. Abstract class
C. Singleton class
D. Friend class

C. Singleton class
COMPUTER PROGRAMMING
Q 49 Which of the following term is used for a function
defined inside a class?

A. Member Variable
B. Member function
C. Class function
D. Classic function

B. Member function
COMPUTER PROGRAMMING
Q 50 Which of the following concept of oops allows
compiler to insert arguments in a function call if it is
not specified?

A. Call by value
B. Call by reference
C. Default arguments
D. Call by pointer

C. Default arguments
COMPUTER PROGRAMMING
Q 51 Which of the following is an abstract data type?

A. int
B. double
C. string
D. class

D. class
COMPUTER PROGRAMMING
Q 52 Which of the following provides a reuse mechanism?

A. Abstraction
B. Inheritance
C. Dynamic binding
D. Encapsulation

B. Inheritance
COMPUTER PROGRAMMING
Q 53 Inheritance occurs when a class adopts all the traits
of

A. an object
B. a parent class
C. a variable
D. a function

B. a parent class
COMPUTER PROGRAMMING
Q 54 Which of the following statement is correct?

A. Class is an instance of object.


B. Object is an instance of a class.
C. Class is an instance of data type.
D. Object is an instance of data type

B. Object is an instance of a class.


COMPUTER PROGRAMMING
Q 55 Which of the following concepts provides facility of
using object of one class inside another class?

A. Encapsulation
B. Abstraction
C. Composition
D. Inheritance

C. Composition
COMPUTER PROGRAMMING
Q 56 Which of the following conceptsmeans wrapping up
of data and functions together?

A. Abstraction
B. Encapsulation
C. Inheritance
D. Polymorphism

B. Encapsulation
COMPUTER PROGRAMMING
Q 57 Which feature of OOP is exhibited by the function
overriding?

A. Polymorphism
B. Encapsulation
C. Abstraction
D. Inheritance

A. Polymorphism
COMPUTER PROGRAMMING
Q 58 Which feature can be implemented using
encapsulation?

A. Polymorphism
B. Overloading
C. Inheritance
D. Abstraction

D. Abstraction
COMPUTER PROGRAMMING
TOPIC PSEUDOCODE

Pseudocode is a high-level description of an algorithm that


combines elements of both natural language and
programming syntax.
Q 59 integer a, b, c
set b = 4, c = 5
for (each a from 2 to 4)
print c
b=b-1
c=c+b
end for

A. 5 8 10 B. 1 3 6
C. 8 9 10 D. 3 6 9

A. 5 8 10
COMPUTER PROGRAMMING
integer a, b, c
set b = 4, c = 5
for (each a from 2 to 4)
print c
b=b-1
c=c+b
end for

COMPUTER PROGRAMMING
Q 60 integer value, n
set value = 1, n = 45
while(value less than equal to n)
value = value << 1
end loop
print value

A. 16 B. 32 C. 64 D. 36

C. 64
COMPUTER PROGRAMMING
integer value, n
set value = 1, n = 45
while(value less than equal to n)
value = value << 1
end loop
print value

COMPUTER PROGRAMMING
Q 61 Which of the following series will be printed by the given
pseudocode?

integer a, b, c
set b = 0, c = 0
for (each a from 1 to 5)
print c
b=b+1
c=c+b
end for

A. 5 4 3 2 1 B. 0 1 3 6 10 C. 2 5 8 9 10 D. 0 0 0 0 0
B. 0 1 3 6 10
COMPUTER PROGRAMMING
integer a, b, c
set b = 0, c = 0
for (each a from 1 to 5)
print c
b=b+1
c=c+b
end for

COMPUTER PROGRAMMING
Q 62 Predict the output of the following pseudo-code

integer a, b, c, d
set b = 10, c = 11
a=b–c
for (each c from 2 to a)
b = b + c + 10
b = b/2
end for
c=a+b+c
print a b c

A. -1 7 9 B. 2 5 8 C. -1 9 19 D. 5 10 13
C. -1 9 19
COMPUTER PROGRAMMING
integer a, b, c, d
set b = 10, c = 11
a=b–c
for (each c from 2 to a)
b = b + c + 10
b = b/2
end for
c=a+b+c
print a b c

COMPUTER PROGRAMMING
Q 63 What will be the output following pseudo code?

integer p,q,r
set p=2, q=5, r=9
if((q+9)<p || (q&p)<p)
r=(p&p)+q
else
p=r+p
end if
r=q+p
print p+q+r

A. 9 B. 14 C. 18 D. 27
B. 14
COMPUTER PROGRAMMING
integer p,q,r
set p=2, q=5, r=9
if((q+9)<p || (q&p)<p)
r=(p&p)+q
else
p=r+p
end if
r=q+p
print p+q+r

COMPUTER PROGRAMMING
Q 64 What will be the output of the following pseudo code for
input a=8 & b=9?

function (input a,input b)


if (a<b)
return function (b,a)
elseif (b!=0)
return (a + function(a,b-1))
else
return 0

A. 56 B. 88 C. 72 D. 65
C. 72
COMPUTER PROGRAMMING
for input a=8 & b=9?

function (input a,input b)


if (a<b)
return function (b,a)
elseif (b!=0)
return (a + function(a,b-1))
else
return 0

COMPUTER PROGRAMMING
Q 65 How many times the following loop be executed?

{
ch = b;
while(ch >= a && ch <= z)
ch++;
}

a) 0 b) 25 c) 26 d) 1

b) 25
COMPUTER PROGRAMMING
Q 66 What will be the value of s if n=127?
Read n
i=0,s=0
Function Sample(int n)
while(n>0)
r=n%l0
p=8^i
s=s+p*r
i++
n=n/10
End While
Return s;
End Function

a) 27 b) 187 c) 87 d) 120

c) 87
COMPUTER PROGRAMMING
if n=127?
Read n
i=0,s=0
Function Sample(int n)
while(n>0)
r=n%l0
p=8^i
s=s+p*r
i++
n=n/10
End While
Return s;
End Function

COMPUTER PROGRAMMING
TOPIC COMPUTER AIDED DESIGN
START
RETHINK

NO Do I want to
do this?

YES

Will it likely NO
end in
RETHINK
disaster?

YES

Will it make a YES


good story DO IT!
anyway?

COMPUTER PROGRAMMING
PROGRAMMING

BY: ENGR. JACOB “COB” MOJARES

You might also like