Eaac0203 LM03
Eaac0203 LM03
0203
Learning Module 03
Computer
Programming Using C
Language
01 0203
Module Overview
Module Overview
Introduction
Learning Outcomes
01 0203
Duration
Delivery Mode
Learning Module 3, Computer Programming Using C Language, will be delivered via onsite
learning (face-to-face), online learning (synchronous) and offsite learning (asynchronous).
The following criteria and the corresponding percentage shall be used to assess the
collaborative learning exercises and laboratory reports as an assessment tool or task.
Criteria Description %
Able to execute calculations correctly by hand and
Calculation apply appropriate mathematical 50%
equations/formulas.
Solution All the answers are correct and properly labeled. 20%
Written work is presented neatly and
Neatness 10%
professionally.
Document Submitted work conforms to the prescribed
10%
Formatting format.
Work is submitted on or before the specified date
Timeliness 10%
and time.
TOTAL 100%
01 0203
Pre-Assessment
Computer Programming Using C Language
Pre-Assessment
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out in an A4 bond paper, write your answers in the space
provided and post a PDF File or captured/scanned image of your paper with cover page in our
Google Classroom. Erasures and abbreviations mean wrong. Keep your work clean and avoid
erasures. Use of pencil is prohibited. Use only a blue ballpoint pen. (20 points)
01 0203
Learning Module 03
Computer
Programming Using C
Language
Course Packet 01
Introduction to Computer
Programming
01 0203
Course Packet 01
Course Packet 01
This course packet introduces the students to the concepts of computer programming,
programming cycle, and algorithm development. Computer programming languages will be
discussed also with flowcharting and pseudocode to familiarize the student in creating
solutions for programming problems. Different programming problems will be discussed to
give students hands-on experience in computer programming solving.
Objectives
At the end of the course packet, the students will be able to:
• Explain the process of the programming cycle and algorithm development.
• Create a flowchart and pseudocode of different gender-responsive programming
problems.
Duration
Delivery Mode
Course Packet 1, Introduction to Computer Programming, will be delivered via onsite learning
(face-to-face), online learning (synchronous) and offsite learning (asynchronous).
The following criteria and the corresponding percentage shall be used to assess the
collaborative learning exercises and laboratory reports as an assessment tool or task.
Criteria Description %
Able to execute calculations correctly by hand and
Calculation apply appropriate mathematical 50%
equations/formulas.
Solution All the answers are correct and properly labeled. 20%
Written work is presented neatly and
Neatness 10%
professionally.
01 0203
Timeliness 10%
and time.
TOTAL 100%
Each student is required to accomplish the collaborative learning exercise and laboratory report
found after reading the course packet. The accomplished collaborative learning exercise and
laboratory report should be posted or submitted at the Google Classroom stream page of the
class on the scheduled date to be given by the faculty in charge.
Readings
01 0203
Introduction
Key Points:
• Computer
instructions about what they should do next. These instructions programming is the act
of writing computer
are known as code, and computer programmers write code to programs, which are a
solve problems or perform a task. The end goal of computer sequence of
instructions written
programming is to create something: that could mean anything using a programming
from a web page, or a piece of software, or even just a pretty language to perform a
specified task by the
picture. It is why computer programming is often described as
computer.
a mix between art and science; it’s technical and analytical, yet • The source code of a
creative at the same time. program is written in
one or more languages
that are intelligible to
Lesson Proper programmers, rather
than machine code,
which is directly
Computer Programming executed by the central
processing unit.
01 0203
of it has its standards in writing. Some examples are C, C++, C#, languages are used in
computer programming
Java, and Perl. The process of creating program code often to implement
requires expertise in program algorithm, design, and logic. Just algorithms. Most
programming
like human languages, programming languages also follow languages consist of
grammar called syntax. Certain basic program code elements are instructions for
computers.
common for all programming languages. The most important
• The description of a
basic elements for programming languages are Programming programming language
is usually split into the
Environment, Data Types, Variables, Keywords, Logical and
two components of
Arithmetical Operators, If else conditions, Loops, Numbers, syntax (form) and
Characters and Arrays, Functions, and Input and Output semantics (meaning).
Algorithm. Algorithm is a
An algorithm is a sequence of unambiguous, finite, and finite sequence of well-
ordered instructions to be followed to solve a problem. Usually defined, computer-
implementable
implements a program algorithm. The instruction sequence instructions, typically to
itself must be finite, not the number of steps taken. The programs solve a class of problems
or to perform a
are usually divided into smaller parts (modules) so that the computation.
algorithm complexity of each of the parties is less than the full Programming
Language. Programming
program, which helps the development of the program. language is a formal
According to Niklaus Wirth, a program consists of algorithms language comprising a set
of instructions that
and data structure. Various techniques have been proposed for produce various kinds of
the program whose goal is to improve the process of creating and output.
Semantics. Semantics is
maintaining software.
the field concerned with
the rigorous mathematical
study of the meaning of
Programming Languages
programming languages.
Syntax. Syntax of a
A programming language is an artificial language that computer language is the
set of rules that defines
can be used to control the behavior of a machine, particularly a the combinations of
computer. Programming languages are used to facilitate symbols that are
considered to be correctly
communication about the task of organizing and manipulating structured statements or
information, and to express algorithms precisely. There are two expressions in that
language.
kinds of programming languages which are low-level
programming language and high-level programming language.
Low-level programming language is consisting of First
Generation and Second Generation. High-level programming
language is consisting of Third, Fourth, and Fifth Generation
01 0203
Key Points:
languages.
• Machine language is
Low-Level Programming Languages made up of a series of
Course Packet 01
01 0203
Key Points:
Course Packet 01
• High-level
programming
languages such as
COBOL, FORTRAN,
BASIC, PASCAL, PL/1,
and C are described
high-level because they
are closer to human
language than to
Figure 246: Compiled Machine Code of the Sample Assembly Code machine language.
Definition of Terms:
High-Level Programming Languages
BASIC. Beginners' All-
purpose Symbolic
High-level programming languages feature is to express Instruction Code is a
algorithms in a way human does, rather than executing like family of general-purpose,
high-level programming
machines. The limitation of the high-level language is that it languages whose design
requires some programming skills to perform the logical philosophy emphasizes
ease of use.
sequence of instructions. The very high-level languages were COBOL. COmmon
created so that users could solve this common problem of data Business-Oriented
Language is a compiled
processing easier and faster. The main advantage of high-level English-like computer
languages over low-level languages is that they are easier to programming language
designed for business
read, write, and maintain. Programs written in a high-level
use.
language must be translated into machine language by a FORTRAN. FORmula
TRANslator is a general-
compiler or interpreter.
purpose, compiled
imperative programming
High-level programming languages are sometimes language that is especially
suited to numeric
divided into three categories: third generation, fourth computation and scientific
generation, and fifth generation. computing.
PASCAL. Pascal is an
1. Third Generation Language (3GL) or High-Level Language imperative and procedural
transformed programming in the early 1960s. It is the first programming language
intended to encourage
to use the true English language which is much easier to use good programming
compared to other low-level languages. If assembler is used practices using structured
programming and data
by the assembly language, third-generation languages use structuring.
the translator to convert the program into a machine PL/I or PL/1.
Programming Language
language. The third generation languages are portable, the One is a procedural,
object code created for one type of system can be translated imperative computer
programming language for
to another different type of system. Some examples are scientific, engineering,
FORTRAN, COBOL, Basic, Pascal, C, C++, and Java. business and system
programming.
2. Fourth Generation Language (4GL) or Very High-Level
Language is closer to human languages than a typical high-
01 0203
Procedural Languages
01 0203
Non-Procedural Languages
01 0203
Algorithm
Pseudocode
01 0203
Example 1:
If student’s grade is greater than or equal to 60
Print “Passed”
Course Packet 01
Else
Print “Failed”
Example 2:
Give variable num1 a starting value of 5
Give variable num2 a starting value of 10
Add 7 to num2
Store the value num1 times num2 in variable num3
Store the value num2 minus num1 in num2
Output num1, num2, and num3
Flowchart
Types of Flowcharts
01 0203
Flowchart Symbols
01 0203
Input/Output
Process
Decision
Preparation
Terminal
Predefined Process
On-Page Connector
01 0203
Off-Page Connector
Course Packet 01
Flow Lines
Flow Direction
Indicators
START
GO TO WORK
A
TAKE A
COFFEE
BREAK
IS IT TIME
Y
TO GO GO HOME
HOME?
N B
STOP
N IS THE
BOSS
A LOOKING?
DO SOME
B
WORK
Flowchart Notations
01 0203
| Logical Or
& Logical And
= or EQ Equal to
Course Packet 01
01 0203
Start
R=1, pi=3.14159
A = pi*R**2
Print R, A
Stop
Pseudocode
Begin
Set R=1, pi=3.14159
A=pi*r**2
Print R, A
End
2. Given three numbers A, B, C. Draw a flowchart to compute
and print out the sum, the average, and the product of these
values.
Identifying the Problem
Given: None
Input: numbers A, B, C
Required: variable S for sum → S = A+B+C
variable a for average → a = (A+B+C)/3
variable P for product → P = A*B*C
Output: S, a, P
01 0203
Start
S = A+B+C
a = (A+B+C)/3
P = A*B*C
Print S, a, P
Stop
Pseudocode
Begin
Print “Input 3 numbers”
Read A, B, C
S = A+B+C
a = (A+B+C)/3
P = A*B*C
Print S, a, P
End
3. The ABC Manufacturing Company plans to give a year-end
bonus to each of its employees. Draw a flowchart that will
compute the bonus of an employee. Consider the following
criteria: If the employee’s monthly salary is less than 1,000.00
pesos, the bonus is 50% of the salary; for employees with
salaries 1,000.00 pesos and above, the bonus is 1,000.00. Print
out the name and corresponding bonus of the employee.
Identifying the Problem
Given: None
Input: variable S for salary → S
variable N for name → N
Required: variable B for bonus → B = ?
01 0203
Start
Is N
B = 1000
S<1000?
Y
A
B = S*0.5
Print N, B
Stop
Pseudocode
Begin
Print “Input name and salary”
Input N, S
If S<1000 Then
B = S*0.5
Else
B = 1000
End If
Print N, B
End
4. Given two numbers X and Y. Draw a flowchart to determine
the difference between X and Y. If X-Y is negative, compute
01 0203
Given: None
Input: numbers X, Y
Required: R = ?
X – Y < 0 then R = X+Y
X – Y = 0 then R = 2*X+2*Y
X – Y > 0 then R = X*Y
Output: X, Y, R
Planning the Solution
Flowchart
Start
Is Y
R = X+Y
X-Y<0?
N
A
Is Y
R = 2*X+2*Y
X-Y=0?
N
A
R = X*Y
Print X, Y, R
Stop
01 0203
Pseudocode
Begin
Print “Input 2 numbers”
Course Packet 01
Input X, Y
If X – Y<0 Then
R = X+Y
Else If X – Y=0 Then
R = 2*X+2*Y
Else
R = X*Y
End If
Print X, Y, R
End
Flowchart Tracing
01 0203
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with a cover page in our Google Classroom.
Keep your work clean and avoid erasures. Use of pencil is prohibited. Use only a blue ballpoint
pen.
Create the flowchart and pseudocode that will determine if the voter can vote in the Barangay
Election, in the Sangguniang Kabataan Election, or not. If the age of the voter is 12 to 17, then
he/she can vote in the Sangguniang Kabataan Election. If the age of the voter is 18 and above,
then he/she can vote in the Barangay Election. Otherwise, the voter cannot vote. Print out the
name of the voter, age, and the message “Congratulations, you can vote in the Sangguniang
Kabataan Election!” or “Congratulations, you can vote in the Barangay Election!” for those that
can vote and “Sorry, you cannot vote!” for those who cannot vote. (30 points)
01 0203
Laboratory Report 6
Introduction to Computer Programming
Laboratory Report 6
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with a cover page in our Google Classroom.
Keep your work clean and avoid erasures. Use of pencil is prohibited. Use only a blue ballpoint
pen.
Create the flowchart and pseudocode that prompts a user to enter a number. After the number
has been entered, display one of the following messages and the number entered. (40 points)
Numbers Message
Below 6 Too Small
6 – 10 Small
11 – 20 Medium
21 – 30 Large
Above 30 Too Large
01 0203
Practical Exam 6
Introduction to Computer Programming
Practical Exam 6
(Topics Covered: All the topics in Course Packet 01 of Learning Module 03)
Remember:
The Practical Exam will be administered face-to-face. You are given an hour to answer this
practical exam. This is an individual assessment, therefore, individual submission of answer to
is required. Cheating in any form is highly discouraged.
01 0203
References
C Tutorial. (n.d.). Retrieved from W3schools.in: https://www.w3schools.in/c-tutorial/intro/
References
Doyle, B. (2014). C# Programming From Problem Analysis to Program Design Fourth Edition. New
Tech Park, Singapore: Cengage Learning Asia Pte Ltd.
Savitch, W. (1996). Problem Solving with C++ The Object of Programming. California, USA:
Addison-Wesley Publishing Company, Inc.
Schildt, H. (1992). Turbo C/C++: The Complete Reference, Second Edition. California, USA:
Osborne Mc-Graw Hill.
Sellappan, P. (2001). C++ Through Examples. Selangor Darul Ehsan, Malaysia: Federal
Publication Sdn. Berhad.
tutorialspoint. (2020). (Tutorials Point (I) Pvt. Ltd.) Retrieved July 3, 2020, from
https://www.tutorialspoint.com/cprogramming/index.htm
01 0203
In what particular portion of this course packet, do you feel that you are struggling or lost?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
To further improve this course packet, what part do you think should be enhanced?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
02
01 0203
Learning Module 03
Computer
Programming Using C
Language
Course Packet 02
C Programming
02 0203
Course Packet 02
Course Packet 02
C Programming
Introduction
This course packet introduces the students to the basic concepts of C Language
programming. C language program structure, data types, and variables will be discussed to
familiarize the student in creating a simple C program with input and output data and
reserving memory locations for data manipulation. Different operators such as arithmetic,
relational and logical operators will also be discussed to give students hands-on experience in
C language programming.
Objectives
At the end of the course packet, the students will be able to:
• Explain the different parts of a C language program.
• Differentiate the different data types, variable types, and operators and how it is used in a
C language program.
• Create gender-responsive source code of different programming problems with the help
of a flowchart and pseudocode.
Duration
Delivery Mode
Course Packet 2, C Programming, will be delivered via onsite learning (face-to-face), online
learning (synchronous) and offsite learning (asynchronous).
The following criteria and the corresponding percentage shall be used to assess the
collaborative learning exercises and laboratory reports as an assessment tool or task.
Criteria Description %
Able to execute calculations correctly by hand and
Calculation apply appropriate mathematical 50%
equations/formulas.
Solution All the answers are correct and properly labeled. 20%
02 0203
10%
Formatting format.
Work is submitted on or before the specified date
Timeliness 10%
and time.
TOTAL 100%
Each student is required to accomplish the collaborative learning exercise and laboratory report
found after reading the course packet. The accomplished collaborative learning exercise and
laboratory report should be posted or submitted at the Google Classroom stream page of the
class on the scheduled date to be given by the faculty in charge.
Readings
02 0203
Introduction
Key Points:
• C language was
Language' (BCPL) called B language which was introduced developed by Dennis
M. Ritchie at the Bell
around the early 1970s. C was invented to write an operating Telephone Laboratories
system called UNIX. The C language was originally designed to in 1972.
• C++ which was an
support procedure-oriented programming. It was subsequently
extension of C
extended to C++ to support object-oriented programming (OOP). language was designed
by Bjarne Stroustrup in
The symbol ++ in C++ indicates that it is an extension of C. Today
1985.
C is the most widely used and popular System Programming
Language. Most of the state-of-the-art software has been Definition of Terms:
02 0203
C++, which has added features, but it's developed from C with
all its initial concepts. In the beginning, C was used for
developing system applications, such as Database Systems,
Course Packet 02
02 0203
Anatomy of a C Program
Sample Program 1:
02 0203
int main ()
{
cout << "Hello World!";
Course Packet 02
return 0;
}
Comment Line
Preprocessor Directive
02 0203
Namespace
Function
02 0203
type int preceding main is the return type, main is the function
name, and the parentheses (), empty but not always, contain the
argument list. A function header is always followed by an open
curly brace, which begins the function body. Each of the related
instructions, or statements, which belong to the main function
are contained within the body of that function. Each statement
inside the function body always ends with a semicolon. The last
statement is a return statement. The function body must contain
a return statement unless the return type is void, in which case
the return statement is optional. Then the function body ends
with a close curly brace.
cout
cout<<“Hello World!”;
“out” refers to the direction in which cout sends a stream
of data. A data stream may flow in one of two directions. One
direction is input, cin>>, into the program from an outside
source. The other direction is output, cout<<, out from the
program to an outside source.
return 0; statement
02 0203
Sample Program 2:
#include <stdio.h>
int main ()
{
printf(“Hello world!\n");
return 0;
}
02 0203
Data Types
02 0203
Size
All C++ data types have a size. A byte is the smallest unit
of information that a computer can process, no data type may be
smaller than one byte. Regardless of the size, the number of
bytes is always a whole number. The number of bytes for a data
type is the result of a power of 2 since computers use a binary
number system. Size of data type matters in two related aspects:
the range of different values that the data type may represent and
the amount of memory required to store the data type.
Range
02 0203
those starting at zero and going down. One of the bits is used to
store the sign, positive or negative.
Course Packet 02
Storage
02 0203
There are two text data types. The first is char, which
stands for character. It is usually is 1 byte, and can represent any
single character, including a letter, a digit, a punctuation mark,
or a space. The second text data type is a string. The string data
type may store several characters, including a sentence, or
paragraph, or page. The number of bytes required depends on
the number of characters involved.
Unlike char and the other data types, the string type is
not a data type built into C++. Instead, it is defined in the
standard library file string, which therefore must be included
with an include directive (#include<string.h>) to use the string
data type.
The bool data type has only two possible values, true
and false, and its size usually is one byte. The term “bool” is a
shortening of Boolean, which is usually used in connection with
Boolean Algebra, named after the British mathematician, George
Boole. It could be regarded as a numeric data type in that zero is
seen as false, and one as true.
sizeof Operator
Sample Program 3:
#include <iostream.h>
int main ()
{
02 0203
Expressions
Outputting Expression
02 0203
Escape Sequence
Variables
Declaring Variables
02 0203
02 0203
Naming Variables
02 0203
Scope of A Variable
Naming Conventions
02 0203
Example:
iNoofStudents = int – data type; No of Students
fAreaofCircle = float – data type; Area of Circle
Course Packet 02
Sample Program 4:
#include <iostream.h>
int main ()
{
int testScore;
cout<<&testScore;
return 0;
}
02 0203
Sample Program 5:
#include <iostream.h>
int main ()
{
short testScore;
float myGPA;
cout<<“The address of testScore is “ <<&testScore <<
“\n”;
cout<<“The size of testScore is “ <<sizeof(testScore) <<
“\n”;
cout<<“The address of myGPA is “ <<&myGPA << “\n”;
cout<<“The size of myGPA is “ <<sizeof(myGPA) <<
“\n”;
return 0;
}
02 0203
Assignment Operator
02 0203
Sample Program 6:
#include <iostream.h>
Course Packet 02
int main ()
{
int testScore;
testScore = 95;
cout<<“Your test score is “ <<testScore << “\n”;
testScore = 75;
cout<<“Your test score now is “ <<testScore << “\n”;
return 0;
}
Sample Program 7:
#include <iostream.h>
int main ()
{
int testScore;
testScore = 77.83;
cout<<“The test score is “<<testScore <<“\n”;
return 0;
}
02 0203
large for its range. The value overflows and wraps around to the
data type’s lowest possible value.
Sample Program 8:
#include <iostream.h>
int main ()
{
short testScore;
testScore = 32768;
cout<<“The test score is “<<testScore <<“\n”;
return 0;
}
Sample Program 9:
#include <iostream.h>
int main ()
{
short testScore;
testScore = -32769;
cout<<“The test score is “<<testScore <<“\n”;
return 0;
02 0203
}
Course Packet 02
#include <iostream.h>
int main ()
{
int testScore;
cin>> testScore;
cout<<“Your testScore is “<<testScore <<“\n”;
return 0;
}
#include <iostream.h>
int main ()
{
int testScore;
cout<<“Enter your test score: “;
02 0203
cin>> testScore;
cout<<“Your testScore is “<<testScore <<“\n”;
return 0;
Course Packet 02
#include <iostream.h>
int main()
{
int myWeight, myHeight;
string myName;
cout<<“Enter your name: ”;
cin>>myName;
cout<<“Enter your weight in pounds: ”;
cin>>myWeight;
cout<<“Enter your height in inches: ”;
cin>>myHeight;
cout<<“Your name score is ” <<myName <<“\n”;
cout<<“Your weight in pounds is ” <<myWeight <<“\n”;
cout<<“Your height in inches is ” <<myHeight <<“\n”;
return 0;
}
02 0203
#include <iostream.h>
int main()
{
int myWeight, myHeight;
string myName;
cout<<“Enter your name, weight in pounds and height
in inches\n: ”;
cin>>myName >>myWeight >>myHeight;
cout<<“Your name score is ” <<myName <<“\n”;
cout<<“Your weight in pounds is ” <<myWeight <<“\n”;
cout<<“Your height in inches is ” <<myHeight <<“\n”;
return 0;
}
The cin operator will only take the first word of a string.
cin object interprets the space between texts as indicating that the
user has finished inputting the value of the variable. The
solutions for this involve using either the get or getline method
of the cin object.
#include <iostream.h>
#include <string.h>
02 0203
int main ()
{
string name;
Course Packet 02
Arithmetic Operators
02 0203
#include <iostream.h>
int main ()
{
int total, added;
cout<<“Enter number of pre-registered students: “;
cin>>total;
cout<<“Enter number of students adding the course: “;
cin>>added;
total = total + added;
cout<<“Total number of students: “ <<total;
return 0;
}
02 0203
Adding Strings
#include <iostream.h>
#include <string.h>
int main ()
{
string firstName = “Jeff”;
string lastName = “Kent”;
cout <<“Your name is “ <<firstName + lastName;
return 0;
}
#include <iostream.h>
int main ()
{
int total, added, dropped;
cout <<“Enter number of pre-registered students: “;
02 0203
#include <iostream.h>
int main ()
{
int total, added, dropped;
cout <<“Enter number of pre-registered students: “;
cin >> total;
cout <<“Enter number of students adding the course: “;
cin >> added;
total = total + added;
cout <<“”How many students dropped? “;
cin >> dropped;
total -= dropped;
cout <<“Total number of students: “ <<total <<endl;
cout <<“Total tuition owed: $” <<(total + dropped) * 72
<<endl;
return 0;
}
02 0203
02 0203
#include <iostream.h>
int main ()
{
int firstOp = 10, secondOp = 4;
float result = firstOp / secondOp;
cout<< firstOp << “ / “ <<secondOp << “ = “ << result;
return 0;
}
#include <iostream.h>
int main ()
{
float firstOp = 10, result;
int secondOp = 4;
result = firstOp / secondOp;
cout<< firstOp << “ / “ <<secondOp << “ = “ << result;
return 0;
}
02 0203
#include <iostream.h>
int main()
{
int firstOp = 10, secondOp = 4;
float result = (float)firstOp / secondOp;
cout<< firstOp << “ / “ <<secondOp << “ = “ << result;
return 0;
}
#include <iostream.h>
int main()
{
int total, added, dropped, tuition;
cout <<“Enter number of pre-registered students: “;
cin >> total;
cout <<“Enter number of students adding the course: “;
cin >> added;
total = total + added;
cout <<“”How many students dropped? “;
cin >> dropped;
total -= dropped;
cout <<“Total number of students: “ <<total <<endl;
tuition =(total + dropped) * 72;
cout <<“Total tuition owed: $ ” <<tuition <<endl;
cout <<“Average tuition per enrolled students:
$” <<(float) tuition/total <<endl;
return 0;
}
02 0203
Exponent
#include <iostream.h>
#include <math.h>
int main()
{
double radius, area;
cout <<“Enter radius of circle: “;
cin >>radius;
area = 3.14159 * pow (radius, 2);
cout <<“The area is “ <<area << endl;
02 0203
return 0;
}
Course Packet 02
02 0203
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with cover page in our Google Classroom. Keep
your work clean and avoid erasures. Use of pencil is prohibited. Use only a blue ballpoint pen.
Create the flowchart of a program that will ask the user to input the value of the temperature
in Celsius, Fahrenheit, Kelvin, and Rankine. The code then will determine the equivalent
temperature in the other units of temperature. Display the input and equivalent temperatures.
Code the resulting flowchart. (C to K, F, R; F to C, K, R; K to C, F, R; and R to C, F, K). (45 points)
02 0203
Laboratory Report 7
C Programming
Laboratory Report 7
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with cover page in our Google Classroom. Keep
your work clean and avoid erasures. Use of pencil is prohibited. Use only a blue ballpoint pen.
Create the flowchart of a program that will ask the user to input the number of pennies. The
code then will determine the equivalent number of dollars, quarters, dimes, nickels, and
pennies from the user input. Display the equivalent number of dollars, quarters, dimes, nickels,
and pennies. Code the resulting flowchart. (Dollar = 100 pennies, Quarters = 25 pennies, Dimes
= 10 pennies, Nickels = 5 pennies and Penny = 1 penny). (25 points)
02 0203
Practical Exam 7
C Programming
Practical Exam 7
(Topics Covered: All the topics in Course Packet 02 of Learning Module 03)
Remember:
The Practical Exam will be administered face-to-face. You are given an hour to answer this
practical exam. This is an individual assessment, therefore, individual submission of answer to
is required. Cheating in any form is highly discouraged.
02 0203
References
C Tutorial. (n.d.). Retrieved from W3schools.in: https://www.w3schools.in/c-tutorial/intro/
References
Doyle, B. (2014). C# Programming From Problem Analysis to Program Design Fourth Edition. New
Tech Park, Singapore: Cengage Learning Asia Pte Ltd.
Savitch, W. (1996). Problem Solving with C++ The Object of Programming. California, USA:
Addison-Wesley Publishing Company, Inc.
Schildt, H. (1992). Turbo C/C++: The Complete Reference, Second Edition. California, USA:
Osborne Mc-Graw Hill.
Sellappan, P. (2001). C++ Through Examples. Selangor Darul Ehsan, Malaysia: Federal
Publication Sdn. Berhad.
tutorialspoint. (2020). (Tutorials Point (I) Pvt. Ltd.) Retrieved July 3, 2020, from
https://www.tutorialspoint.com/cprogramming/index.htm
02 0203
In what particular portion of this course packet, do you feel that you are struggling or lost?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
To further improve this course packet, what part do you think should be enhanced?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
02
03 0203
Learning Module 03
Computer
Programming Using C
Language
Course Packet 03
Selection Structures
03 0203
Course Packet 03
Course Packet 03
Selection Structures
Introduction
This course packet introduces the students to the different selection structures and
different relational operators to be used in a C program. The selection structure’s function and
syntax will be discussed with the students to familiarize themselves in its usage and be able to
manipulate the flow of the process in a program. Different relational operators will also be
discussed and demonstrated to give students hands-on experience in data and process
manipulation in a C program.
Objectives
At the end of the course packet, the students will be able to:
• Make use of the different selection structures to manipulate the process flow of a C
program.
• Create gender-responsive source code of different programming problems with the help
of a flowchart and pseudocode.
Duration
Delivery Mode
Course Packet 3, Selection Structures, will be delivered via onsite learning (face-to-face), online
learning (synchronous) and offsite learning (asynchronous).
The following criteria and the corresponding percentage shall be used to assess the
collaborative learning exercises and laboratory reports as an assessment tool or task.
Criteria Description %
Able to execute calculations correctly by hand and
Calculation apply appropriate mathematical 50%
equations/formulas.
Solution All the answers are correct and properly labeled. 20%
03 0203
10%
Formatting format.
Work is submitted on or before the specified date
Timeliness 10%
and time.
TOTAL 100%
Each student is required to accomplish the collaborative learning exercise and laboratory report
found after reading the course packet. The accomplished collaborative learning exercise and
laboratory report should be posted or submitted at the Google Classroom stream page of the
class on the scheduled date to be given by the faculty in charge.
Readings
03 0203
Introduction
Key Points:
• C programming
blocks of computer programs. They are commands that enable a language assumes any
non-zero and non-null
program to make decisions, following one path or another. A values as true, and if it
program is usually not limited to a linear sequence of is either zero or null,
then it is assumed as
instructions since during its process it may divide, repeat code false value.
or avoid sections. Control Structures are the blocks that analyze • Selection structures
require that the
variables and choose directions in which to go based on given
programmer specifies
parameters. one or more conditions
to be evaluated by the
program, along with
Lesson Proper statements to be
executed if the
condition is determined
Making Decision to be true, and
optionally, other
statements to be
Computer programs present their users with choices. executed if the
The flow of each program has followed a relatively straight line, condition is determined
to be false.
taking a predetermined path from beginning to end. However,
as programs become more sophisticated, they often branch in Definition of Terms:
two or more directions based on a choice a user makes. Function call. A control
structure that is used to
invite or call a piece of
The program determines the action it takes by code or statement. In this
comparing the user’s choice with the various alternatives. case control jumps from
main program to that
Comparison is made using a relational operator. The relational
piece of code and then
operators are used to test for equality, inequality, whether one returns back to main
program.
value is greater (or less) than another, and other comparisons.
Repetition Structures. A
control structure where
The code then needs to be structured so different code the statements are
executed more than one
executes depending on which choice was made. It could be done time. It is also known as
using the if statement or the switch case statement. Flowcharting iteration or loop.
Selection Structures. A
enables the programmer to visually depict the flow of a program. control structure that
It becomes increasingly helpful in transitioning from relatively selects a statement to
execute on the basis of
simple programs that flow in a straight line to more complex condition. Statement is
programs that branch in different directions. executed when the
condition is true and
ignored when it is false.
Relational Operators Sequential Structures. A
control structure that is
executed in a specified
Humans make comparisons all the time, and so do order. No statement is
skipped and executed
programs. A program may need to determine whether one value more than once.
03 0203
Operator Meaning
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
== Equal to
!= Not equal to
Relational Expressions
#include <iostream.h>
int main ()
{
int a = 4, b = 5;
cout<< a <<“ > ” << b <<“ is “ << (a > b) << endl;
cout<< a <<“ >= ” << b <<“ is “ << (a >= b) << endl;
cout<< a <<“ == ” << b <<“ is “ << (a == b) << endl;
cout<< a <<“ <= ” << b <<“ is “ << (a <= b) << endl;
cout<< a <<“ < ” << b <<“ is “ << (a < b) << endl;
return 0;
}
03 0203
be the same. However, the data types of the two operands need
to be compatible.
Course Packet 03
Precedence
The if Statement
#include <iostream.h>
03 0203
int main ()
{
int num;
Course Packet 03
Indenting
Common Mistakes
03 0203
03 0203
Syntax:
if (relational expression)
conditional statement;
else
conditional statement;
#include <iostream.h>
int main ()
{
int num;
cout << “Enter a whole number: ”;
cin >> num;
if (num % 2 == 0)
cout << “The number is even” << endl;
else
cout << “The number is odd” << endl;
return 0;
}
Common Mistakes
No else Without an if
03 0203
Example:
if (num % 2 == 0);
cout << “The number is even” << endl;
else (num % 2 == 1)
cout << “The number is odd” << endl;
03 0203
Conditional Operator
#include <iostream.h>
int main ()
{
int num;
cout << “Enter a whole number: ”;
cin >> num;
cout << “The number is “<< (num % 2 == 0? “even”:
“odd”) << endl;
return 0;
}
03 0203
#include <iostream.h>
int main ()
{
03 0203
int testScore;
cout <<“Enter your test score: ”;
cin >> testScore;
Course Packet 03
03 0203
case value1:
statement/s;
break;
Course Packet 03
case value2:
statement/s;
break;
⋮
default:
statement/s;
}
#include <iostream.h>
int main ()
{
char grade;
cout << “Enter your grade: ”;
cin >> grade;
switch (grade)
{
case ‘A’:
cout<< “Your average must be between
90 - 100” <<endl;
break;
case ‘B’:
cout << “Your average must be between
80 - 89” <<endl;
break;
case ‘C’:
cout << “Your average must be between
70 - 79” <<endl;
break;
case ‘D’:
cout << “Your average must be between
60 - 69” <<endl;
break;
default:
cout<< “Your average must be below
03 0203
60” <<endl;
}
return 0;
Course Packet 03
03 0203
Falling Through
#include <iostream.h>
int main ()
{
char grade;
cout <<“Enter your grade: ”;
cin >> grade;
switch (grade)
{
case ‘a’:
case ‘A’:
cout << “Your average must be between
90 - 100” <<endl;
break;
case ‘b’:
case ‘B’:
cout << “Your average must be between
80 - 89” <<endl;
break;
case ’c’:
case ‘C’:
cout << “Your average must be between
70 - 79” <<endl;
03 0203
break;
case ‘d’:
case ‘D’:
Course Packet 03
#include <iostream.h>
int main ()
{
char choice;
cout <<“Choose your car\n ”;
cout <<“S for Standard\n ”;
cout <<“L for Leather Seats\n ”;
cout <<“D for Leather Seats + Chrome Wheels\n ”;
cin >> choice;
cout <<“Extra features purchased\n ”;
switch (choice)
{
case ‘D’:
cout << “Chrome wheels\n”;
case ‘L’:
cout << “Leather seats\n”;
break;
default:
cout << “None selected\n”;
}
return 0;
}
03 0203
Range of Numbers
03 0203
case 85:
case 84:
case 83:
Course Packet 03
case 82:
case 81:
case 80:
cout << “Your grade is a B”;
break;
}
Nested if Statements
03 0203
#include <iostream.h>
int main ()
{
int age;
char choice;
bool citizen;
cout << “Enter your age: “;
cin >> age;
cout << “Are you a citizen (Y/N): “;
cin >> choice;
if (choice == ‘Y’)
citizen = true;
else
citizen = false;
if (age >= 18)
if (citizen == true)
cout << “You are eligible to vote “;
else
cout << “You are not eligible to vote “;
else
cout << “You are not eligible to vote “;
return 0;
}
03 0203
#include <iostream.h>
int main ()
{
int age;
cout << “Enter your age: “;
cin >> age;
if (age > 12)
if (age >= 65)
cout << “Admission is free “;
else
cout << “You have to pay “;
else
cout << “Admission is free “;
return 0;
}
Alternative:
if (age <= 12)
cout << “Admission is free”;
else if (age >= 65)
cout << “Admission is free”;
else
cout << “You have to pay”;
03 0203
Logical Operators
#include <iostream.h>
int main ()
{
int age;
char choice;
bool citizen;
03 0203
The || Operator
03 0203
#include <iostream.h>
Course Packet 03
int main ()
{
int age;
cout << “Enter your age: “;
cin >> age;
if (age <= 12 || age >= 65)
cout << “Admission is free “;
else
cout << “You have to pay “;
return 0;
}
The ! Operator
03 0203
#include <iostream.h>
Course Packet 03
int main ()
{
int age;
cout << “Enter your age: “;
cin >> age;
if (! (age > 12 && age < 65))
cout << “Admission is free “;
else
cout << “You have to pay “;
return 0;
}
Precedence
03 0203
Example:
if (! (age > 12 && age < 65))
if (! age > 12 && age < 65)
Course Packet 03
03 0203
Alternative:
switch (age >= 18 && citizen == true)
{
Course Packet 03
case true:
cout << “You are eligible to vote “;
break;
case false:
cout << “You are not eligible to vote “;
}
Example:
if (age <= 12 || age >= 65)
cout << “Admission is free “;
else
cout << “You have to pay “;
Alternative:
switch (age <= 12 || age >= 65)
{
case true:
cout << “Admission is free “;
break;
case false:
cout << “You have to pay “;
}
03 0203
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with a cover page in our Google Classroom.
Keep your work clean and avoid erasures. Use of pencil is prohibited. Use only a blue ballpoint
pen.
The initial value of the radius of a circle is equal to one unit and each succeeding radius is one
unit greater than the value before it. Draw a flowchart to compute the area of the circle starting
with R=1.0 to R=5.0, then print out each radius and the corresponding area of the circle. Code
the resulting flowchart. (25 points)
03 0203
Laboratory Report 8
Selection Structures
Laboratory Report 8
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with a cover page in our Google Classroom.
Keep your work clean and avoid erasures. Use of pencil is prohibited. Use only a blue ballpoint
pen.
Create a flowchart that finds the sum of the first 50 natural numbers and displays the final sum.
Code the resulting flowchart. (25 points)
03 0203
Practical Exam 8
Selection Structures
Practical Exam 8
(Topics Covered: All the topics in Course Packet 03 of Learning Module 03)
Remember:
The Practical Exam will be administered face-to-face. You are given an hour to answer this
practical exam. This is an individual assessment, therefore, individual submission of answer to
is required. Cheating in any form is highly discouraged, individual submission of the answer
to the Schoology account where this is posted is required.
03 0203
References
C Tutorial. (n.d.). Retrieved from W3schools.in: https://www.w3schools.in/c-tutorial/intro/
References
Doyle, B. (2014). C# Programming From Problem Analysis to Program Design Fourth Edition. New
Tech Park, Singapore: Cengage Learning Asia Pte Ltd.
Savitch, W. (1996). Problem Solving with C++ The Object of Programming. California, USA:
Addison-Wesley Publishing Company, Inc.
Schildt, H. (1992). Turbo C/C++: The Complete Reference, Second Edition. California, USA:
Osborne Mc-Graw Hill.
Sellappan, P. (2001). C++ Through Examples. Selangor Darul Ehsan, Malaysia: Federal
Publication Sdn. Berhad.
tutorialspoint. (2020). (Tutorials Point (I) Pvt. Ltd.) Retrieved July 3, 2020, from
https://www.tutorialspoint.com/cprogramming/index.htm
03 0203
In what particular portion of this course packet, do you feel that you are struggling or lost?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
To further improve this course packet, what part do you think should be enhanced?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
03
04 0203
Learning Module 03
Computer
Programming Using C
Language
Course Packet 04
Repetition Structures
04 0203
Course Packet 04
Course Packet 04
Repetition Structures
Introduction
This course packet introduces the students to the different repetition structures and
increment and decrement operators to be used in a C program. Repetition structure’s function
and their syntax will be discussed with the students to familiarize themselves in its usage and
be able to manipulate the flow of the process in a program. Increment and decrement operators
with relation to other operators will also be discussed and demonstrated to give students
hands-on experience in data and process manipulation in a C program.
Objectives
At the end of the course packet, the students will be able to:
• Make use of the different repetition structures to manipulate the process flow of a C
program.
• Create gender-responsive source code of different programming problems with the help
of a flowchart and pseudocode.
Duration
Delivery Mode
Course Packet 4, Repetition Structures, will be delivered via onsite learning (face-to-face),
online learning (synchronous) and offsite learning (asynchronous).
The following criteria and the corresponding percentage shall be used to assess the
collaborative learning exercises and laboratory reports as an assessment tool or task.
Criteria Description %
Able to execute calculations correctly by hand and
Calculation apply appropriate mathematical 50%
equations/formulas.
Solution All the answers are correct and properly labeled. 20%
04 0203
10%
Formatting format.
Work is submitted on or before the specified date
Timeliness 10%
and time.
TOTAL 100%
Each student is required to accomplish the collaborative learning exercise and laboratory report
found after reading the course packet. The accomplished collaborative learning exercise and
laboratory report should be posted or submitted at the Google Classroom stream page of the
class on the scheduled date to be given by the faculty in charge.
Readings
04 0203
Introduction
Key Points:
• C programming
variables. It can structure programming statements to be language assumes any
non-zero and non-null
repeated as long as specific conditions are met. For example, a values as true, and if it
program can input, add, and average multiple numbers using a is either zero or null,
then it is assumed as
limited number of variables. There are three looping structures false value.
in C, the for loop, while loop, and do...while Loop. • Repetition structures,
or loops, are used
when a program needs
Lesson Proper to repeatedly process
one or more
instructions until some
Repetition Structure condition is met, at
which time the loop
ends.
In the world of programming, sometimes there is a need
to repeat the execution of code multiple times. For example, if Definition of Terms:
the user enters invalid data, the program may ask the user Function call. A control
whether they want to retry or quit. If they retry and still enter structure that is used to
invite or call a piece of
invalid data, the program will again ask the user whether they code or statement. In this
want to retry or quit. This process keeps repeating until the user case control jumps from
main program to that
either enters valid data or quits. piece of code and then
returns back to main
program.
Use a loop to repeat the execution of code statements. A Repetition Structures. A
loop in C++ is a structure that repeats the execution of code until control structure where
the statements are
a condition becomes false. The process of performing the same
executed more than one
task over and over again is called iteration, and C++ provides time. It is also known as
iteration or loop.
built-in iteration functionality. A loop executes the same section
Selection Structures. A
of program code over and over again, as long as a loop condition control structure that
of some sort is met with each iteration. This section of code can selects a statement to
execute on the basis of
be a single statement or a block of statements (a compound condition. Statement is
statement). executed when the
condition is true and
ignored when it is false.
Increment and Decrement Operators Sequential Structures. A
control structure that is
executed in a specified
Increment means to increase a value by one while order. No statement is
skipped and executed
decrement means to decrease a value by one. C++ has an more than once.
increment operator that can be used to increase a value by one
and a decrement operator that can be used to decrease a value by
one.
04 0203
#include <iostream.h>
int main()
{
int num = 2;
num += 1;
cout << num;
return 0;
}
#include <iostream.h>
int main ()
{
int num = 2;
num++;
cout << num;
return 0;
}
Alternative:
#include <iostream.h>
int main ()
{
int num = 2;
++num;
cout << num;
return 0;
}
04 0203
#include <iostream.h>
int main ()
{
int num = 2;
num -= 1;
cout << num;
return 0;
}
#include <iostream.h>
int main ()
{
int num = 2;
num--;
cout << num;
return 0;
}
04 0203
Alternative:
#include <iostream.h>
int main ()
Course Packet 04
{
int num = 2;
--num;
cout << num;
return 0;
}
#include <iostream.h>
int main ()
{
int num = 2;
cout << num++;
return 0;
}
#include <iostream.h>
int main ()
{
int num = 2;
cout << num++;
return 0;
04 0203
04 0203
#include <iostream.h>
int main ()
{
int num = 1;
cout << num++;
cout << num++;
cout << num++;
cout << num++;
cout << num++;
cout << num++;
cout << num++;
cout << num++;
cout << num++;
cout << num++;
return 0;
}
#include <iostream.h>
int main ()
{
for (int num = 1; num <= 10; num++)
cout << num << “ “;
return 0;
}
Another Program:
#include <iostream.h>
int main ()
{
for (int num = 1; num <= 100; num++)
cout << num << “ “;
04 0203
return 0;
}
Course Packet 04
The for loop is one of the three types of loops; the other
two are the while and do while loop. A loop is a structure that
repeats the execution of code until a condition becomes false.
Each repetition is called an iteration.
Syntax:
for (initialization; condition; update)
statement;
04 0203
{
cout << num << “ “;
cout << “Next Loop “;
Course Packet 04
}
Also, as with the if structure, the statement or statements
following the for keyword and parentheses will not execute if the
parentheses are followed by a semi-colon since that would be
interpreted as an empty statement.
Example:
for (int num = 1; num <= 10; num++);
cout << num << “ “;
The expressions do not need to be inside the parentheses
following the for loop.
#include <iostream.h>
int main ()
{
int num = 1;
for (; num <= 10;)
{
cout << num << “ “;
num++;
}
return 0;
}
Even though initialization and incrementing are not done within
the parentheses, two semicolons are nevertheless within the
parentheses to separate where the three expressions would be.
04 0203
#include <iostream.h>
int main ()
{
int num = 1;
for(; num <= 10;)
{
cout << num << “ ”;
}
return 0;
}
#include <iostream.h>
int main ()
{
int num, counter, secret = 3;
04 0203
{
cout << “Enter the number now: “;
cin >> num;
if (num == secret)
{
cout << “You guessed the secret
number!”;
break;
}
}
cout << “Program over”;
return 0;
}
Normally, the for loop has one exit point, the condition
when it becomes false. However, when one or more break
statements are used, the for loop has multiple exit points. The
disadvantage of using a break in a for loop is that it makes the
code difficult to understand, and can result in logic errors.
#include <iostream.h>
int main ()
{
int n;
for (n=10; n>0; n--)
{
cout << n << ", ";
if (n==3)
{
cout << "countdown aborted!";
break;
}
}
return 0;
04 0203
#include <iostream.h>
int main ()
{
int num, counter, secret = 3;
cout << “Guess a number between 1 and 10\n “;
cout << “You have 3 trials\n “;
bool keepgoing = true;
for (int counter = 1; counter <= 3 && keepgoing ==
true; counter++)
{
cout << “Enter the number now: “;
cin >> num;
if (num == secret)
{
cout << “You guessed the secret
number!”;
keepgoing = false;
}
}
cout << “Program over”;
return 0;
}
#include <iostream.h>
int main ()
{
04 0203
int num = 1;
for ( ; ; )
{
Course Packet 04
#include <iostream.h>
int main ()
{
int num, counter, total = 0;
cout << “How many items do you want to buy: “;
cin >> num;
for ( int counter = 1; counter <= num; counter++ )
{
if (counter % 4 == 0)
continue;
total += 3;
}
04 0203
cout << “Total for “<< num << “ items is $” << total;
return 0;
}
Course Packet 04
#include <iostream.h>
int main ()
{
int num, counter, total = 0;
cout << “How many items do you want to buy: “;
cin >> num;
for (int counter = 1; counter <= num; counter++)
{
if (!(counter % 4 == 0))
total += 3;
}
cout << “Total for “ << num << “ items is $” << total;
return 0;
}
It is possible to use the relational != (not equal) operator,
changing the if statement to if (counter % 4 != 0).
#include <iostream.h>
int main ()
{
for (int n=10; n>0; n--)
{
if (n==5) continue;
cout << n << ", ";
}
cout << "FIRE!";
04 0203
return 0;
}
Course Packet 04
Syntax:
for (expressionO1; expressionO2; expressionO3)
{
for (expressionI1; expressionI2; expressionI3)
statementI;
statementO;
}
#include <iostream.h>
int main ()
{
for (int x = 1; x <= 5; x++)
{
for (int y = 1; y <= 10; y++)
cout << “X“;
cout << “\n”;
}
return 0;
}
With nested for loops, for each iteration of the outer for
loop, the inner for loop goes through all its iterations.
#include <iostream.h>
int main ()
{
for (int x = 1; x <= 5; x++)
04 0203
{
for (int y = 1; y <= 10; y++)
cout << “X“;
Course Packet 04
#include <iostream.h>
int main ()
{
int persons, int numSales;
cout << “Enter number of salespersons: “;
cin >> persons;
cout << “Enter number of sales per salesperson: “;
cin >> numSales;
for (int x = 1; x <= persons; x++)
{
int sale, total = 0;
float average;
for (int y = 1; y <= numSales; y++)
{
cout << “Enter sale “<< y << “ for
salesperson “ << x << “: “;
cin >> sale;
total += sale;
}
average = (float) total / numSales;
cout << “Average sales for salesperson #” << x
<< “ is “ << average << endl;
}
return 0;
}
04 0203
The for loop generally is used when the loop will iterate
a fixed number of times. However, sometimes the number of
times a loop will iterate is unpredictable, depending on user
input during runtime. While the total number of loop iterations
may be unpredictable, there often are situations in which the
loop will iterate at least once.
#include <iostream.h>
int main ()
{
for (int num = 1; num <= 10; num++)
cout << num << “ “;
return 0;
}
Alternative:
#include <iostream.h>
int main ()
{
int num = 1;
while (num <= 10)
{
04 0203
return 0;
}
The two statements in the body of the while loop could have been
combined into one statement, cout << num++.
04 0203
Example:
while (num <= 10)
{
Course Packet 04
#include <iostream.h>
int main ()
{
int num = 0;
while (num++ < 10)
cout << num << “ “;
return 0;
}
#include <iostream.h>
int main ()
{
int n;
cout << "Enter the starting number > ";
04 0203
cin >> n;
while (n>0)
{
Course Packet 04
#include <iostream.h>
int main ()
{
int num;
cout << “Enter a positive number: “;
cin >> num;
while (num <= 0)
{
cout << “Number must be positive; please
retry: “;
cin >> num;
}
cout << “The number you entered is “<< num << “ “;
return 0;
}
04 0203
they are going to enter any data at all, they should have the
option, when told the data entered was not valid, of quitting the
data entry.
#include <iostream.h>
int main ()
{
int num;
char choice;
cout << “Enter a positive number: “;
cin >> num;
while (num <= 0)
{
cout << “Number must be positive; try again
(Y/N): “;
cin >> choice;
if (choice == ‘Y’)
{
cout << “Enter number: “;
cin >> num;
}
else
break;
}
cout << “The number you entered is “<< num << “ “;
return 0;
}
Flags
04 0203
#include <iostream.h>
int main ()
{
int num;
char choice;
bool quit = false;
cout << “Enter a positive number: “;
cin >> num;
while (num <= 0 && quit == false)
{
cout << “Number must be positive; try again
(Y/N): “;
cin >> choice;
if (choice == ‘Y’)
{
cout << “Enter number: “;
cin >> num;
}
else
quit = true;
}
if (quit == false)
cout << “The number you entered is “<< num
<< “ “;
else
cout << “You did not enter a positive number”;
return 0;
}
04 0203
While (true)
while loop always true, such as while (true) or while (1), and
break out of the while loop with the break keyword. The use of
the while (true) syntax has the disadvantage of making the code
less readable because the condition that stops the loop cannot be
discerned from the parentheses following the while keyword.
The do while loop avoids this disadvantage and would be a
preferable choice.
#include <iostream.h>
int main ()
{
int num;
char choice;
bool quit = false;
while (true)
{
cout << “Enter a positive number: “;
cin >> num;
if (num > 0)
break;
else
{
cout << “Number must be positive; try
again (Y/N): “;
cin >> choice;
if (choice != ‘Y’)
{
quit = true;
break;
}
}
}
if (quit == false)
cout << “The number you entered is “<< num
04 0203
<< “ “;
else
cout << “You did not enter a positive number“;
Course Packet 04
return 0;
}
#include <iostream.h>
int main ()
{
int num, counter = 0, total = 0;
cout << “How many items do you want to buy: “;
cin >> num;
while (counter++ < num)
{
if (counter % 13 == 0)
continue;
total += 3;
}
cout << “Total for “<< num << “ items is $” << total;
return 0;
}
04 0203
#include <iostream.h>
Course Packet 04
int main()
{
int num, counter = 0, total = 0;
cout << “How many items do you want to buy: “;
cin >> num;
while (counter++ < num)
{
if (!(counter % 13 == 0))
total += 3;
}
cout << “Total for “ << num << “ items is $” << total;
return 0;
}
#include <iostream.h>
04 0203
int main ()
{
int x = 0;
Course Packet 04
04 0203
#include <iostream.h>
int main ()
{
int num;
char choice;
bool quit = false;
do {
cout << “Enter a positive number: “;
cin >> num;
if (num <= 0)
{
cout << “Number must be positive; try
again (Y/N): “;
cin >> choice;
if (choice != ‘Y’)
quit = true;
}
} while (num <= 0 && quit == false);
if (quit == false)
cout << “The number you entered is “<< num
<< “ “;
else
cout << “You did not enter a positive number“;
return 0;
}
#include <iostream.h>
int main ()
{
04 0203
unsigned long n;
do {
cout << "Enter number (0 to end): ";
Course Packet 04
cin >> n;
cout << "You entered: " << n << "\n";
} while (n != 0);
return 0;
}
Scope
04 0203
04 0203
#include <iostream.h>
Course Packet 04
int main ()
{
int x = 0;
do {
int y = 0;
do {
cout << “X”;
} while (y++ < 5);
cout << “\n”;
} while (x++ < 5);
return 0;
}
Jump Statements
04 0203
04 0203
the execution of the current function and pass the return value
contained in the expression (if any) to the function that invoked
it. The value returned must be of the same type or convertible to
the same type as the function. If necessary, more than one return
statement may be placed in a function. The execution of the first
return statement in the function automatically terminates the
function.
Syntax:
return expression;
# include <iostream.h>
int main ()
{
float y1, y2, avgy;
float avg (float, float);
y1 = 5.0;
y2 = 7.0;
avgy = avg (y1, y2);
cout << “\nThe average = “ <<avgy;
return 0;
}
float avg (float x1, float x2)
{
float avgx;
avgx = (x1 + x2)/2;
return avgx;
}
04 0203
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with a cover page in our Google Classroom.
Keep your work clean and avoid erasures. Use of pencil is prohibited. Use only a blue ballpoint
pen.
Given a set of 5 numbers that include both positive and negative data values. Draw a flowchart
to read in these values one at a time and count the number of positive values (including zero
values) and the number of negative values found in the set. After the required values are
determined, print out these counted values. Code the resulting flowchart. (40 points)
04 0203
Laboratory Report 9
Repetition Structures
Laboratory Report 9
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with a cover page in our Google Classroom.
Keep your work clean and avoid erasures. Use of pencil is prohibited. Use only a blue ballpoint
pen.
Create the flowchart that will produce the figure below. Code the resulting flowchart. (45
points)
04 0203
Practical Exam 9
Repetition Structures
Practical Exam 9
(Topics Covered: All the topics in Course Packet 04 of Learning Module 03)
Remember:
The Practical Exam will be administered face-to-face. You are given an hour to answer this
practical exam. This is an individual assessment, therefore, individual submission of answer to
is required. Cheating in any form is highly discouraged.
04 0203
References
C Tutorial. (n.d.). Retrieved from W3schools.in: https://www.w3schools.in/c-tutorial/intro/
References
Doyle, B. (2014). C# Programming From Problem Analysis to Program Design Fourth Edition. New
Tech Park, Singapore: Cengage Learning Asia Pte Ltd.
Savitch, W. (1996). Problem Solving with C++ The Object of Programming. California, USA:
Addison-Wesley Publishing Company, Inc.
Schildt, H. (1992). Turbo C/C++: The Complete Reference, Second Edition. California, USA:
Osborne Mc-Graw Hill.
Sellappan, P. (2001). C++ Through Examples. Selangor Darul Ehsan, Malaysia: Federal
Publication Sdn. Berhad.
tutorialspoint. (2020). (Tutorials Point (I) Pvt. Ltd.) Retrieved July 3, 2020, from
https://www.tutorialspoint.com/cprogramming/index.htm
04 0203
In what particular portion of this course packet, do you feel that you are struggling or lost?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
To further improve this course packet, what part do you think should be enhanced?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
04
05 0203
Learning Module 03
Computer
Programming Using C
Language
Course Packet 05
05 0203
Course Packet 05
Course Packet 05
This course packet introduces the students to the function and array construction to be
used in a C program. Creating, defining, and calling a function as well as the different ways of
passing data to and from different functions will be discussed to the students to familiarize
themselves in its usage and be able to manipulate the flow of data in a program. Different uses
of arrays will also be discussed and demonstrated to give students hands-on experience in data
manipulation in a C program.
Objectives
At the end of the course packet, the students will be able to:
• Make use of functions and arrays to manipulate the data and process flow of a C program.
• Create the gender-responsive source code of different programming problems with the
help of flowchart and pseudocode.
Duration
Delivery Mode
Course Packet 5, Function and Arrays will be delivered via onsite learning (face-to-face), online
learning (synchronous) and offsite learning (asynchronous).
The following criteria and the corresponding percentage shall be used to assess the
collaborative learning exercises and laboratory reports as assessment tool or task.
Criteria Description %
Able to execute calculations correctly by hand and
Calculation apply appropriate mathematical 50%
equation/formula.
Solution All the answers are correct and properly labeled. 20%
Written work is presented neatly and
Neatness 10%
professionally.
05 0203
Timeliness 10%
and time.
TOTAL 100%
Each student is required to accomplish the collaborative learning exercise and laboratory report
found after reading the course packet. The accomplished collaborative learning exercise and
laboratory report should be posted or submitted at the Google Classroom stream page of the
class on the scheduled date to be given by the faculty-in-charge.
Readings
05 0203
Introduction
Key Points:
• A function is a block of
building blocks known as function. A large C program can easily code that performs a
specific task.
be tracked when it is divided into multiple functions. Also, by • While creating a C
using functions, programmer can avoid rewriting same logic or function, give a
definition of what the
code again and again in a program. C functions can also be called
function has to do. To
any number of times in a program and from any place in a use a function, call that
function to perform the
program that provide reusability and modularity in a program.
defined task.
• The size and type of
An array is used to store a collection of data, but it is an array cannot be
changed once it is
often more useful to think of an array as a collection of variables declared.
of the same type. Instead of declaring individual variables, such
Definition of Terms:
as num0, num1, ..., and num99, programmer can declare one
array variable such as num and use num[0], num[1], and ..., Array. Arrays a kind of
data structure that can
num[99] to represent individual variables. A specific element in store a fixed-size
an array is accessed by an index. sequential collection of
elements of the same
type.
Lesson Proper Function call. A control
structure that is used to
invite or call a piece of
Function code or statement. In this
case control jumps from
main program to that
A function is a group of statements that together piece of code and then
returns back to main
perform a task. Programmer can divide up the code into
program.
separate functions. How to divide up the code among different Repetition Structures. A
functions is up to the programmer, but logically the division control structure where
the statements are
usually is so each function performs a specific task. For example, executed more than one
a program that performs arithmetic calculations, one function time. It is also known as
iteration or loop.
obtains user input, another function performs the calculation, Selection Structures. A
and a third function performs output of the result. control structure that
selects a statement to
execute on the basis of
There are advantages to dividing the code into separate condition. Statement is
executed when the
functions in addition to making the code easier to understand. condition is true and
For example, if a function performs a specific task, such as ignored when it is false.
Sequential Structures. A
sending output to a printer, which is performed several times in control structure that is
a program, the programmer only needs to write once in a executed in a specified
order. No statement is
function the code necessary to send output to the printer, and skipped and executed
then call that function each time the programmer needs to more than once.
perform that task.
05 0203
two steps which are defining the function and calling the
function.
Terminology of a Function
#include <iostream.h>
int main ()
{
cout << “Hello World!”;
return 0;
}
The first line, int main (), is the function header. Unlike
a statement, the function header is not followed by a semicolon.
The function header consists of a return type, a function name,
and an argument list. The data type int preceding main is the
return type, main is the function name, and the parentheses (),
empty but not always, contains the argument list. A function
header always is followed by an open curly brace, which begins
the function body.
05 0203
Defining a Function
#include <iostream.h>
void printMessage (void)
{
cout << “Hello World!”;
}
int main ()
{
printMessage();
return 0;
}
Calling a Function
05 0203
Prototyping
#include <iostream.h>
int main ()
{
printMessage();
return 0;
}
void printMessage (void)
{
cout << “Hello World!”;
}
05 0203
#include <iostream.h>
void printMessage (void);
int main ()
{
printMessage ();
return 0;
}
void printMessage (void)
{
cout << “Hello World!”;
}
Local Variables
05 0203
#include <iostream.h>
Course Packet 05
void printMessage(void);
int main ()
{
int times = 0;
char choice;
do {
cout << “Enter Q to quit, any other character to
continue: “;
cin >> choice;
if (choice == ‘Q’)
cout << “Input stopped”;
else
printMessage ();
} while (choice != ‘Q);
return 0;
}
void printMessage (void)
{
times ++;
cout << “This function called “<< times << “ times\n” ;
}
#include <iostream.h>
void printMessage(void);
int main ()
05 0203
{
char choice;
do {
Course Packet 05
Global Variables
05 0203
#include <iostream.h>
Course Packet 05
void printMessage(void);
int times;
int main ()
{
times = 0;
char choice;
do {
cout << “Enter Q to quit, any other character to
continue: “;
cin >> choice;
if (choice == ‘Q’)
cout << “Input stopped”;
else
printMessage ();
} while (choice != ‘Q);
return 0;
}
void printMessage (void)
{
times ++;
cout << “This function called “<< times << “ times\n” ;
}
05 0203
the global variable’s lifetime did not end until the entire program
ended. A static local variable is different.
Course Packet 05
#include <iostream.h>
void printMessage(void);
int times;
int main ()
{
char choice;
do {
cout << “Enter Q to quit, any other character to
continue: “;
cin >> choice;
if (choice == ‘Q’)
cout << “Input stopped”;
else
printMessage ();
} while (choice != ‘Q);
return 0;
}
void printMessage (void)
{
static int times = 0;
times ++;
cout << “This function called “<< times << “ times\n” ;
05 0203
#include <iostream.h>
#include <string.h>
void printMessage(void);
string str;
int main ()
{
cout << “Enter a string: “;
cin >> str;
printMessage ();
return 0;
}
void printMessage ()
{
cout << “You inputted “<< str;
}
#include <iostream.h>
#include <string.h>
05 0203
void printMessage(string);
int main ()
{
Course Packet 05
string str;
cout << “Enter a string: “;
cin >> str;
printMessage (str);
return 0;
}
void printMessage (string s)
{
cout << “You inputted “<< s;
}
05 0203
or
printMessage (str);
void printMessage (string s)
Course Packet 05
#include <iostream.h>
#include <string.h>
void printMessage(string, string,int);
int main ()
{
string name1, name2;
int a=0;
cout << “Enter the first name: “;
cin >> name1;
cout << “Enter the second name: “;
cin >> name2;
printMessage (name1, name2, a);
return 0;
}
void printMessage (string firstName, string lastName, int x)
{
cout << “Your name is “<< firstName << “ “
<< lastName << endl<<x;
}
05 0203
#include <iostream.h>
Course Packet 05
#include <string.h>
void printMessage (string, int);
int main ()
{
string name;
int age;
cout << “Enter the first name: “;
cin >> name1;
cout << “Enter the second name: “;
cin >> name2;
cout << “Enter name: “;
cin >> name;
cout << “Enter age: “;
cin >> age;
printMessage(name, age);
return 0;
}
void printMessage (string theName, int theAge)
{
cout << “Your name is “<< theName << “ and your age
is “ << theAge << endl;
}
#include <iostream.h>
void doubleIt(int);
int main ()
{
05 0203
int num;
cout << “Enter number: “;
cin >> num;
Course Packet 05
doubleIt(num);
cout << “The number doubled in main is “ << num
<< endl;
return 0;
}
void doubleIt (int x)
{
cout << “The number to be doubled is “ << x << endl;
x *= 2;
cout << “The number doubled in doubleIt is “ << x
<< endl;
}
#include <iostream.h>
void doubleIt(int&);
int main ()
{
int num;
cout << “Enter number: “;
cin >> num;
doubleIt(num);
cout << “The number doubled in main is “<< num
<< endl;
return 0;
}
05 0203
x *= 2;
cout << “The number doubled in doubleIt is “<< x
<< endl;
}
#include <iostream.h>
void addNumbers (int, int, int&);
int main ()
{
int firstNum, secondNum, sum = 0;
cout << “Enter first number: “;
cin >> firstNum;
cout << “Enter second number: “;
cin >> secondNum;
addNumbers(firstNum, secondNum, sum);
cout << firstNum << “ + “ << secondNum << “ = “
<< sum;
return 0;
}
05 0203
#include <iostream.h>
int addNumbers (int, int);
int main ()
{
int firstNum, secondNum, sum = 0;
cout << “Enter first number: “;
cin >> firstNum;
cout << “Enter second number: “;
cin >> secondNum;
sum = addNumbers (firstNum, secondNum);
cout << firstNum << “ + “ << secondNum << “ = “
<< sum;
return 0;
}
int addNumbers (int x, int y)
{
return x + y;
}
05 0203
header. The function’s return value is the value that follows the
return keyword.
Course Packet 05
Array
05 0203
Declaring an Array
Constants
05 0203
#include <iostream.h>
int main ()
{
int testScore[3];
return 0;
}
#include <iostream.h>
int main ()
{
int numTests;
cout << “Enter the number of test scores:”;
cin >> numTests;
int testScore[numTests];
return 0;
}
05 0203
#include <iostream.h>
int main ()
{
const int numTests = 3;
int testScore[numTests];
return 0;
}
#include <iostream.h>
int main ()
{
05 0203
int testScore[numTests];
return 0;
}
#include <iostream.h>
int main ()
{
const int numTests = 3;
int num;
cout << “Enter the number of test scores:”;
cin >> num;
numTest = num;
int testScore[numTests];
return 0;
}
05 0203
Array Index
Initialization
05 0203
05 0203
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with a cover page in our Google Classroom.
Keep your work clean and avoid erasures. Use of pencil is prohibited. Use only blue ballpoint
pen.
Create the flowchart of the program that will combine the programs done in CLE 8, 9, and 10
and Laboratory Report 7, 8, and 9. The program will prompt the user to choose which program
to run. The program should utilize function, also array if necessary, for code division. The
main function should only contain the data input and display. The processing should happen
in other functions. (30 points)
05 0203
Laboratory Report 10
Functions and Arrays
Laboratory Report 10
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with a cover page in our Google Classroom.
Keep your work clean and avoid erasures. Use of pencil is prohibited. Use only blue ballpoint
pen.
Code the flowchart of the program that will combine the programs done in CLE 8, 9, and 10
and Laboratory Report 7, 8, and 9. The program will prompt the user to choose which program
to run. The program should utilize function, also array if necessary, for code division. The
main function should only contain the data input and display. The processing should happen
in other functions. (65 points)
05 0203
Practical Exam 10
Functions and Arrays
Practical Exam 10
Remember:
The Practical Exam will be administered face-to-face. You are given an hour to answer this
practical exam. This is an individual assessment, therefore, individual submission of answer to
is required. Cheating in any form is highly discouraged.
05 0203
References
C Tutorial. (n.d.). Retrieved from W3schools.in: https://www.w3schools.in/c-tutorial/intro/
References
Doyle, B. (2014). C# Programming From Problem Analysis to Program Design Fourth Edition. New
Tech Park, Singapore: Cengage Learning Asia Pte Ltd.
Savitch, W. (1996). Problem Solving with C++ The Object of Programming. California, USA:
Addison-Wesley Publishing Company, Inc.
Schildt, H. (1992). Turbo C/C++: The Complete Reference, Second Edition. California, USA:
Osborne Mc-Graw Hill.
Sellappan, P. (2001). C++ Through Examples. Selangor Darul Ehsan, Malaysia: Federal
Publication Sdn. Berhad.
tutorialspoint. (2020). (Tutorials Point (I) Pvt. Ltd.) Retrieved July 3, 2020, from
https://www.tutorialspoint.com/cprogramming/index.htm
05 0203
In what particular portion of this course packet, do you feel that you are struggling or lost?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
To further improve this course packet, what part do you think should be enhanced?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
05
06 0203
Learning Module 03
Computer
Programming Using C
Language
Course Packet 06
Graphics Manipulation
06 0203
Course Packet 06
Course Packet 06
Graphics Manipulation
Introduction
This course packet introduces the students to the different commands to be used to
create a graphical design in a C program. The graphics command’s function and their syntax
will be discussed to the students to familiarize themselves in its usage and be able to
manipulate the output screen. Different graphical manipulation will also be discussed and
demonstrated to give students hands-on experience in output screen manipulation in a C
program.
Objectives
At the end of the course packet, the students will be able to:
• Make use of the different graphics commands to manipulate the output screen using a C
program.
• Create the gender-responsive source code of different programming problems with the
help of flowchart and pseudocode.
Duration
Delivery Mode
Course Packet 6, Graphics Manipulation, will be delivered via onsite learning (face-to-face),
online learning (synchronous) and offsite learning (asynchronous).
The following criteria and the corresponding percentage shall be used to assess the
collaborative learning exercises and laboratory reports as assessment tool or task.
Criteria Description %
Able to execute calculations correctly by hand and
Calculation apply appropriate mathematical 50%
equation/formula.
Solution All the answers are correct and properly labeled. 20%
06 0203
10%
Formatting format.
Work is submitted on or before the specified date
Timeliness 10%
and time.
TOTAL 100%
Each student is required to accomplish the collaborative learning exercise and laboratory report
found after reading the course packet. The accomplished collaborative learning exercise and
laboratory report should be posted or submitted at the Google Classroom stream page of the
class on the scheduled date to be given by the faculty-in-charge.
Readings
06 0203
Introduction
Key Points:
• In a C program, first
geometrical shapes such as rectangle, circle, ellipse and step is to initialize the
graphics drivers on the
polygons, to draw curves using mathematical function, to color computer. This is done
an object with different colors and patterns, and simple using the initgraph ()
method provided in
animation programs like jumping ball and moving cars. graphics.h library.
Definition of Terms:
Lesson Proper
Computer Graphics.
Computer graphics is the
Turbo C Graphics
use of computers to
create and manipulate
Turbo C is an Integrated Development Environment and pictures or image or
drawings on a display
compiler for the C programming language from Borland. It was device. It comprises of
first introduced in 1987 and was noted for its integrated software techniques to
create, store, modify,
development environment, small size, fast compile speed, represents pictures or
comprehensive manuals and low price. In May 1990, Borland image or drawings.
DOSBox. DOSBox is a
replaced Turbo C with Turbo C++. free and open-source
emulator of an Intel x86
personal computer
C graphics using graphics.h functions can be used to designed for the purpose
draw different shapes, display text in different fonts, change of running software
created for disk operating
colors and many more. Using functions of graphics.h in Turbo systems on IBM PC
C compiler you can make graphics programs, animations, compatibles, primarily
DOS video games.
projects, and games. Programmer can draw circles, lines, Turbo C. Turbo C is a C
rectangles, bars and many other geometrical figures. Programming Language
compiler that transforms
Programmer can also change their colors using the available
programs written in C to
functions and fill them. Assembly or Machine
code to create an
executable Program.
How to Use DOSBox or TurboCdroid TurboCdroid.
TurboCdroid is specially
designed for
1. Open DOSBox or TurboCdroid. School/college students to
2. Go to File and select DOS Shell. run Turbo C++ on android
platform.
3. In DOS Shell change the directory from bin to bgi to run
graphics mode.
C:\TC\BIN>cd..
C:\TC>cd bgi
C:\TC\BGI>exit
4. Go to File and select New to start a new program
06 0203
#include<graphics.h>
clrscr()
getch()
initgraph()
06 0203
*pathtodriver);
cleardevice()
closegraph()
setcolor()
06 0203
Course Packet 06
setbkcolor()
setlinestyle()
The function which sets the style for all lines drawn by
line, lineto, rectangle, drawpoly, and so on.
Syntax:
setlinestyle(int linestyle, unsigned upattern, int
thickness);
06 0203
setfillstyle()
The function which sets the current fill pattern and fill
color.
Syntax:
setfillstyle(int pattern, int color);
settextstyle()
06 0203
Syntax:
settextstyle(int font, int direction, int font_size);
Course Packet 06
settextjustify()
06 0203
getmaxx()
getmaxy()
getmaxcolor()
getx()
gety()
06 0203
line()
to point(x2,y2) i.e. (x1,y1) and (x2,y2) are end points of the line.
Syntax:
line(x1, y1, x2, y2);
lineto()
linerel()
circle()
arc()
06 0203
pieslice()
center at (x, y) and given radius r. The slice travels from s_angle
to e_angle which are starting and ending angles for the pie slice.
The angles for pie-slice are given in degrees and are measured
counterclockwise.
Syntax:
pieslice(int x, int y, int s_angle, int e_angle, int r);
ellipse()
fillellipse()
sector()
06 0203
rectangle()
bar()
bar3d()
drawpoly()
06 0203
Syntax:
drawpoly(int num, int *polypoints );
Course Packet 06
fillpoly()
floodfill()
outtext()
outtextxy()
getimage()
06 0203
image is stored.
Syntax:
getimage(int left, int top, int right, int bottom, void
*bitmap);
putimage()
06 0203
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with a cover page in our Google Classroom.
Keep your work clean and avoid erasures. Use of pencil is prohibited. Use only blue ballpoint
pen.
Create the program that will produce the figure below. The larger circle should have a diameter
of 80, the smaller circle should have a diameter of 40 and the arc should have a start angle of
269, end angle of 40 and diameter of 88. Use only one command in creating each shape. (25
points)
175,240
420,340
150,250
450,400
260,400 350,400
280,410 281,411
06 0203
Laboratory Report 11
Graphics Manipulation
Laboratory Report 11
Name: Score:
Section: Date:
Sex at Birth:
Instructions. Kindly print this out on an A4 bond paper, write your answers and post a PDF
File or captured/scanned image of your paper with a cover page in our Google Classroom.
Keep your work clean and avoid erasures. Use of pencil is prohibited. Use only blue ballpoint
pen.
Create a program that will produce the pie chart of the annual work output report of each
employee at the center screen with a diameter of 360, background color 8 and outline and font
color 12. The percentages of the work done by the employees are: Andy 5%, Ben 18%, Catty
7%, Don 15%, Eddy 4%, Frank 15%, Gary 14%, Helen 10%, Ivan 3% and Jack 9%. Draw it in
sequence and use the pattern 11, 9, 5, 7, 10, 2, 8, 3, 6, 4 and color 1, 14, 5, 3, 7, 2, 13, 6, 9, 4
respectively. Print the title EMPLOYEE ANNUAL WORK OUTPUT REPORT at 320, 430
horizontally using size 2 and font face 4 with center justification. Output also the subtitle
BASED ON PERCENTAGES OF TOTAL WORK DONE at 320, 460 with the same settings of
the title. (35 points)
06 0203
Practical Exam 11
Graphics Command
Practical Exam 11
(Topics Covered: All the topics in Course Packet 06 of Learning Module 03)
Remember:
The Practical Exam will be administered face-to-face. You are given an hour to answer this
practical exam. This is an individual assessment, therefore, individual submission of answer to
is required. Cheating in any form is highly discouraged.
06 0203
References
C Tutorial. (n.d.). Retrieved from W3schools.in: https://www.w3schools.in/c-tutorial/intro/
References
Doyle, B. (2014). C# Programming From Problem Analysis to Program Design Fourth Edition. New
Tech Park, Singapore: Cengage Learning Asia Pte Ltd.
Savitch, W. (1996). Problem Solving with C++ The Object of Programming. California, USA:
Addison-Wesley Publishing Company, Inc.
Schildt, H. (1992). Turbo C/C++: The Complete Reference, Second Edition. California, USA:
Osborne Mc-Graw Hill.
Sellappan, P. (2001). C++ Through Examples. Selangor Darul Ehsan, Malaysia: Federal
Publication Sdn. Berhad.
tutorialspoint. (2020). (Tutorials Point (I) Pvt. Ltd.) Retrieved July 3, 2020, from
https://www.tutorialspoint.com/cprogramming/index.htm
06 0203
In what particular portion of this course packet, you feel that you are struggling or lost?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
To further improve this course packet, what part do you think should be enhanced?
_____________________________________________________________________________
_____________________________________________________________________________
__________________________________________________________________________
03 0203
Post-Assessment
Post-Assessment
03 0203
03 0203
Program : _____________________________________________________________
Year Level : ________ Section : _____ Sex at Birth: ___________
Faculty : _____________________________________________________________
Schedule : ____________
_______________________________________________