You are on page 1of 87

Computer Fundamentals and ProgrammingComputer Fundamentals and

ProgrammingComputer Fundamentals and ProgrammingComputer


Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
TERMINOLOGIES:

Program - A set of instructions, written in a specific programming language, which a


computer follows in processing data, performing an operation, or solving a logical
problem.

Software – Programs

Hardware - Physical component of a computer

DATA vs. INFORMATION

DATA – a collection of facts relating to events that take place. These facts could be in
the form of numbers, letters, special symbols or combination of these.

INFORMATION – data that has been organized and processed so that it is meaningful.
It is essential for effective performance of management functions of planning, organizing,
directing, and controlling for effective internal operations and external reporting.
Course Material for CS10 Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87Course Material for CS10
Page 1 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

DATA PROCESSING CYCLE

The process of converting data into useful and meaningful information:

INPUT PROCESS OUTPUT

THE PROGRAMMING CYCLE

1.) Defining the Problem


2.) Developing Software Requirements
3.) Designing the Program
4.) Coding the Program

Course Material for CS10 Page 2 of 87Course Material for CS10


Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87Course Material for CS10
Page 2 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
5.) Checking out the program by Testing and Debugging
6.) Installing and Maintaining the Program
7.) Documentation

Program Elements and Structure


 
1.)     Constants – Literal Value that does not change during program execution. It can
be of the numeric or string type.
 
Numeric Constant - may be an integer (whole number) or a real number (with a
decimal place). It may be preceded by a positive or negative sign.
Examples:
10 -28 +3.4 -0.413 0 201
 
Note: No other characters must or can appear together with the constants. The
following are examples of incorrect numeric constants:
 
Course Material for CS10 Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87Course Material for CS10
Page 3 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
10,000 $14.3 10mi/hr 1/2
 
String Constant – A character or group of characters enclosed in double quotation
marks ( “ ). The numbers 0-9, letters a-z or A-Z and all special characters like a space,
% $ - _ & etc. may be included.
 
Examples:
“C” “Tina” “.” “1225” “B & L”
 
Note: The entire string constant must always be enclosed in double quotation marks,
one before the first character and one after the last character (no more no less). The
following are examples of incorrect string constants:
 
“Cristina A. Pascua ACT” “Power Plant

2.) Variables – Is a portion of the computer’s main memory used to store a numeric or
string constant. The value stored in the variable must be given a unique variable name
but it can only hold one value at a given time.
Course Material for CS10 Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87Course Material for CS10
Page 4 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
 Variable names must conform to the following requirements:
 
a.)    Must contain only letters, numbers and/or an underscore.
b.)    Must begin with a letter.
c.)    Must Stop either with a letter or a number.
d.)    Must be unique that is, not a name of another variable.
e.)    Must not be a keyword like IF, WHILE and the like.
 
Note: Variable names are case sensitive, that is, upper and lower case letters are
differentiated. For example the variable TOTAL is not the same as total.
The following are example of incorrect variable name:

  Year code 10ctr #5 Total=

 3.) Expressions – is a group of program elements consisting of operands and


operators. Operands can be a constant, variable, and or an array element. Operators
can be arithmetic, logical, relational and/or string. Expressions always yield a value of
a certain type depending on the type of expressions used.
Course Material for CS10 Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87Course Material for CS10
Page 5 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

Arithmetic Expressions
 
Hierarchy or Priority of Operators

1.)     Expressions in parenthesis


2.)     * / %
3.)     + -

Examples: 
1.)     10 + 4 * 8
= 10 + 32
= 42
 
2.)     50 % 6 – 5
Course Material for CS10 Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87Course Material for CS10
Page 6 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
=2–5
= -3
 
3.)     20 / 4 * 9
=5*9
= 45

String Expressions
 
Examples:
 
1.)     “3” + “4” = “34”
2.)     “Cris” + “tina” = ”Cristina”
 
Examples of incorrect usage of the + operator:
 
“3” + 4 100 + “Peso”

Course Material for CS10 Page 7 of 87Course Material for CS10


Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87Course Material for CS10
Page 7 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Relational Expressions

Greater than > Less than or equal to <=


Less than < Not equal !=
Greater than or equal to >= Is equal to ==

Examples:

Ctr1 > 10 3 <= 5 Temp1 != Temp2


 
Examples of incorrect Relational Expressions:
 
30 <= X <= 40 43 > < 50

Logical Expressions
 
Course Material for CS10 Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87Course Material for CS10
Page 8 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Hierarchy or Priority of Operators

1.)     Expressions in parenthesis


2.)     Not (!)
3.)     And (&&)
4.)     Or (||)
 

TRUTH TABLE FOR NOT(!)

X !X
FALSE TRUE
TRUE FALSE

TRUTH TABLE FOR AND(&&)

X Y X && Y
Course Material for CS10 Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87Course Material for CS10
Page 9 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
FALSE FALSE FALSE
FALSE TRUE FALSE
TRUE FALSE FALSE
TRUE TRUE TRUE

TRUTH TABLE FOR OR(||)

X Y X || Y
FALSE FALSE FALSE
FALSE TRUE TRUE
TRUE FALSE TRUE
TRUE TRUE TRUE

Examples:
 
15 >= 10 && 15 <= 20
T && T
Course Material for CS10 Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87Course Material for CS10
Page 10 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
T
 
Statements – are keywords, which perform a predefined procedure. The following
statements are available:
 
1.)     IF Statement
2.) WHILE Statement
3.)     FOR Statement

Exercises:
 
1.)     11 % 2 + 3 * 7 –2
2.)     100 % 5 % 3 % 2
3.)     – (45 / 9) * 6 + 4
4.)     (5 + 7) % (10 * 2 – 5) / (15 – (8 – 6 % 4))
5.)     (8 + 21 % (18 – 5 * 3)) % (17 – (6 + 13 % 5))
6.)     (12 == 12 % 2 * 2) && !(( 5 > 3) && (8<3))
7.)     (6 > 3) && (8 != 8) || !(10 <= 10)
Course Material for CS10 Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87Course Material for CS10
Page 11 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
8.)     15 / 3 == 15 % 3
9.)     5 != 11 / 2

Exercises:
 
10.) Number of enrollees exceeded 5,000 students.
11.) HEIGHT is at least 170 cm.
12.) REVENUE is at most 80% of SALES.
13.) X is either 6, 8 , or 10
14.) X is any number except 1, 2, and 3.
15.) X is between 100 and 200.

FLOWCHARTS
Course Material for CS10 Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87Course Material for CS10
Page 12 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

- A graphic form of an algorithm.


- A diagram of a sequence of steps that a program must perform to produce the
desired output.
- Traditional tool of programmers which allow flexibility in terms of detail to be
included.

TYPES OF FLOWCHARTS

1.) System Flowchart – present the total picture without worrying about taking
care of every detail.
2.) Program Flowcharts – depicts a main segment of a complete computer
program.

FLOWCHARTING GUIDELINES

1.) Always use the ANSI standard symbols.


2.) Construct your flowcharts to read from top to bottom and left to right.
Course Material for CS10 Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87Course Material for CS10
Page 13 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
3.) Do not crisscross flow lines (used labeled connectors and use arrowheads to
indicate direction of the flow.
4.) Make the messages and labels in the flowchart symbol direct and descriptive.
5.) Strive for neatness, clarity and simplicity.

Course Material for CS10 Page 14 of 87Course Material for CS10


Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87Course Material for CS10
Page 14 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

BASIC FLOWCHARTING SYMBOLS

Course Material for CS10 Page 15 of 87Course Material for CS10


Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87Course Material for CS10
Page 15 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Terminal Symbol

Preparation Symbol

Processing Symbol

Decision Symbol

Course Material for CS10 Page 16 of 87Course Material for CS10


Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87Course Material for CS10
Page 16 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Input/Output Symbol

Predefined Process Symbol

Onpage Connector

Offpage Connector

Flow Direction Lines

Course Material for CS10 Page 17 of 87Course Material for CS10


Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87Course Material for CS10
Page 17 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

Punched Card

Magnetic Tape

Online Storage

Document Printout

Course Material for CS10 Page 18 of 87Course Material for CS10


Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87Course Material for CS10
Page 18 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

Course Material for CS10 Page 19 of 87Course Material for CS10


Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87Course Material for CS10
Page 19 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

C++ SPECIFICS

Course Material for CS10 Page 20 of 87Course Material for CS10


Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87Course Material for CS10
Page 20 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Data Types

Type Size Range of Values


unsigned short int 2 bytes 0 to 65, 535
short int 2 bytes -32,768 to 32,767
unsigned long int 4 bytes 0 to 4, 294,967,295
long int 4 bytes -2,147,483,648 to 2,147,483,647
int 4 bytes -2,147,483,648 to 2,147,483,647
unsigned int 4 bytes 0 to 4, 294,967,295
char 1 bytes 256 characters
bool 1 bytes true or false
float 4 bytes 1.2e-38 to3.4e38
double 8 bytes 2.2e-308 to 1.8e308

Escape Sequence Character

Course Material for CS10 Page 21 of 87Course Material for CS10


Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87Course Material for CS10
Page 21 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Character combinations consisting of a backslash (\) followed by a letter or by a
combination of digit is called "escape sequences."

Escape Sequence Represents


\a Bell (alert)
\b Backspace
\f Formfeed
\n New line
\r Carriage return
\t Horizontal tab
\v Vertical tab
\' Single quotation mark
\" Double quotation mark
\\ Backslash
\? Literal question mark
Course Material for CS10 Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87Course Material for CS10
Page 22 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
\ ooo ASCII character in octal notation
\x hh ASCII character in hexadecimal notation
\x hhhh Unicode character in hexadecimal notation
if this escape sequence is used in a wide-
character constant or a Unicode string
literal.
For example, WCHAR f = L'\x4e00' or
WCHAR b[] = L"The Chinese character for
one is \x4e00".

C++ SPECIFICS

Compound Operators

Course Material for CS10 Page 23 of 87Course Material for CS10


Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87Course Material for CS10
Page 23 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
In addition to basic Arithmetic operators, compound operators are available in C++.

The following are the compound Operators in C++: *=, /=, %=, +=, and - =

Normal Arithmetic Expression Arithmetic Expression Using Compound


Operators

Var = Var * 2 Var *= 2

Var = Var / 3 Var /= 3

Var = Var % 5 Var %= 5


Var += 4
Var = Var + 4
Var -= 1
Var = Var – 1

Course Material for CS10 Page 24 of 87Course Material for CS10


Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87Course Material for CS10
Page 24 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Unary Operators (Prefix and Postfix)

The available unary operators in C++ are ++ which increments a variable by 1 and - -
which decrements a variable by 1. It can be written as PREFIX or before the variable or
POSTFIX after the variable.

PREFIX Example: ++X or --X

POSTFIX Example: X++ or X--

#include<iostream.h>
Sample Program 1 : int main()
{ int num1=1, num2=2;

num1++; cout<<num1++<<endl;
Course Material for CS10 Page 25 of 87Course Material for CS10
++num2; cout<<num2++<<endl<<endl;
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
} Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Value of num1 = 2 and value of25
Page num2 =3
of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87Course Material for CS10
Page 25 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

Sample Program 2 : #include<iostream.h>


int main()
{ int num1=1, num2=2;

++num1; cout<<++num1<<endl;

num2++; cout<<++num2<<endl<<endl;

Value of num1 = 3 and value of num2 = 4

Course Material for CS10 Page 26 of 87Course Material for CS10


Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87Course Material for CS10
Page 26 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

A SIMPLE C++ PROGRAM

Course Material for CS10 Page 27 of 87Course Material for CS10


Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87Course Material for CS10
Page 27 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

/*This program will prompt the user to input length and width
of a rectangle and compute and output its area*/
//Programmer: CRISTINA A. PASCUA 1
#include<iostream.h> 2
int main() 3
{ int length, width, area;
4
5
cout<<“Input length and width of a rectangle: “;
6
cin>>length>>width;
area = length * width; 7
cout<<“ Area of a rectangle = “<<area;
Course Material for CS10 Page 28 of 87Course Material for CS10
8 for CS10
Page 28 of 87Course Material
return 0; Page 28 of 87Course Material for CS10
} 9Material for CS10
Page 28 of 87Course
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87Course Material for CS10
Page 28 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

ELEMENTS OF A C++ PROGRAM

1.) comment – represented by // for a single line comment


and /* */ for multiple line comments.
2.) compiler directives
3.) main function
4.) variables
5.) data types
data types includes the following: int, float, double, char
6.) special characters
; - terminates a statement
Course Material for CS10 Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87Course Material for CS10
Page 29 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
, - separates variable names of the same type
() – used in function declaration and function call
{ } – begin and end symbol
7.) expressions – can be arithmetic, relational and logical
8.) reserved word – cannot be used as a user defined identifier.
example: return, int, float, double, char, for, while, do, etc.
9.) statements - any line terminated by a semicolon

 Basic input statement used in C++ is cin

syntax: cin>>variable_name;
cin>>var1>>var2>>var3;
example: cin>>num;
cin>>num1>>num2>>num3;

 Basic output statement used in C++ is cout



syntax: cout<<variable_name;
Course Material for CS10 Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87Course Material for CS10
Page 30 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
cout<<var1<<var2<<var3;
cout<<“string”;
cout<<“string”<<variable_name;
example: cout<<num;
cout<<num1<<num2<<num3;
cout<<“Hello Philippines Mabuhay!”;
cout<<“Sum = “<<sum;

Course Material for CS10 Page 31 of 87Course Material for CS10


Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87Course Material for CS10
Page 31 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

SEQUENTIAL PROGRAM STRUCTURE

1.) Create a flowchart and a c++ program that will input temperature in Celsius and
output the corresponding temperature in Fahrenheit.

The formula is a follows:

Fahrenheit = 9 (Celsius) + 32
5

Course Material for CS10 Page 32 of 87Course Material for CS10


Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87Course Material for CS10
Page 32 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart
C++ Program

Start #include <iostream.h>

void main()
F=0 {
double F, C;
Input C F = 0;
cout<<” Input temperature in Celsius: ”;
cin>> C;
F = (9.0/5.0) * C + 32 F = (9.0 / 5.0) * C + 32;
cout<< “Temperature in Fahrenheit:”<<F<<endl;
}
Output F

Course Material for CS10 Page 33 of 87Course Material for CS10


End Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87Course Material for CS10
Page 33 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

Course Material for CS10 Page 34 of 87Course Material for CS10


Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87Course Material for CS10
Page 34 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
2.) Pepperoni++ Pizza House charges 10% service charge and 5% sales tax on the
gross bill of the customer. Create a flowchart and a c++ program that would input the
gross bill of the customer and the amount given by the customer to the waiter. It must
output the customer’s total bill and change (if there’s any).

Course Material for CS10 Page 35 of 87Course Material for CS10


Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87Course Material for CS10
Page 35 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart C++ Program

Start #include<iostream.h>

void main()
TBill = 0
{ int GBill, Amt, change, TBill;
change = 0
TBill = 0;
change = 0;
Input GBill, Amt cout<< ” Input Gross Bill and Amount Given: ”;
cin>> GBill>> Amt;
TBill = GBill + GBill * 0.1 + GBill * 0.05;
TBill = Gbill + Gbill *0.1 + Gbill * 0.05 change = Amt – Tbill;
change = Amt - TBill
cout<< “Total Bill = ”<< Tbill<<endl;
cout<< “Change = ”<< change<<endl;
Output TBill, change }

Course Material for CS10 Page 36 of 87Course Material for CS10


End Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87Course Material for CS10
Page 36 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

Course Material for CS10 Page 37 of 87Course Material for CS10


Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87Course Material for CS10
Page 37 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

3.) Ten young men agreed to purchase a gift worth RO10.000 for their idol: Lady Gogo.
In addition, they agreed to continue with their plan even if at least one of them drops out.
Create a flowchart and a c++ program that would input the number of men who dropped
out (assume 0 to 9 only) and output how much more will each have to contribute toward
the purchase of the gift.

C++ Program

#include <iostream.h>
Course Material for CS10 Page 38 of 87Course Material for CS10
void main() Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
{ double DO, AC;38 of 87Course Material for CS10
Page
AC = 0;
Page 38 of 87Course Material for CS10
cout<< ” Input
Pagenumber of menMaterial
38 of 87Course who dropped out:
for CS10 ”;
cin>> DO; Page 38 of 87Course Material for CS10
AC =Page 38 of 87Course
(1000.00 Material
* DO) / (10 for CS10
– DO);
Page 38 of 87Course Material for CS10
cout “Additional
Page 38Contribution
of 87Course=”<< AC<<endl;
Material for CS10
} Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
Page 38 of 87Course Material for CS10
Page 38 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart

Start

AC = 0

Input DO

AC = (1000.00 * DO) / (10-DO)

Output AC

Course Material for CS10 Page 39 of 87Course Material for CS10


End Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87Course Material for CS10
Page 39 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

4.) Create a flowchart and a c++ program that would input an integer number and then
output its one’s digit or the right most digit.

Course Material for CS10 Page 40 of 87Course Material for CS10


Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87Course Material for CS10
Page 40 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart
C++ Program
Start
#include<iostream.h>

RDigit = 0 void main()


{ int num, RDigit;
RDigit = 0;
Input num cout<< ” Input an integer number: ”;
cin>> num;
RDigit = num % 10;
RDigit = num % 10 cout<< “It’s rightmost digit is ”<<RDigit<<endl;
}

Output RDigit

End for CS10


Course Material Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87Course Material for CS10
Page 41 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

5.) Workers at a particular company were given a 15.5% salary increase. Moreover, the
increase was retroactive for 2 months, that is, effective two months ago. Create a
flowchart and a c++ program that takes the employee’s old salary as input and then
output the amount of retroactive pay (balance) due the employee and his new salary as
well.

Course Material for CS10 Page 42 of 87Course Material for CS10


Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87Course Material for CS10
Page 42 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart C++ Program

#include <iostream.h>
Start
void main()
Retro = 0 { double OS, Retro, NS;
NS = 0
Retro = 0;
NS = 0;
Input OS cout<<” Input employees old salary: ”;
cin>>OS;
Retro = (OS * 0.155) * 2;
Retro = (OS *0.155) *2 NS = OS + OS * 0.155;
NS = OS + OS * 0.155 cout<<“Retroactive pay = ”<<Retro<<endl;
cout<<“New salary = ”<<NS<<endl;
}
Output Retro, NS
Course Material for CS10 Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
End Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87Course Material for CS10
Page 43 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

Course Material for CS10 Page 44 of 87Course Material for CS10


Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87Course Material for CS10
Page 44 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

6.) Create a flowchart and a c++ program that would input numeric values to A, B, C, D
and exchange their values such that A goes to B, B goes to C, C goes to D, and D goes
to A.

Course Material for CS10 Page 45 of 87Course Material for CS10


Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87Course Material for CS10
Page 45 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart C++ Program
Start
#include <iostream.h>

Temp = 0 void main()


{ int A, B, C, D, Temp;

Input A, B, C, D cout<< ” Input values for A, B, C, and D: ”;


cin>> A>> B>> C>> D;
Temp = A;
Temp = A A = D;
A=D D = C;
D=C C = B;
C=B B = Temp;
B = Temp cout<< A<<endl<< B<<endl<< C<<endl<< D<<endl;
}
Output A, B, C, D
Course Material for CS10 Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
End Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87Course Material for CS10
Page 46 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

SELECTION/CONDITIONAL PROGRAM STRUCTURE

1.) Create a flowchart and a c++ program that will prompt the user to input two numbers
and output the highest number entered.

Course Material for CS10 Page 47 of 87Course Material for CS10


Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87Course Material for CS10
Page 47 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart C++ Program
Start
#include <iostream.h>

Input N1, N2 void main()


{ int N1, N2;

Y cout<<” Input two numbers: ”;


If Output N1 cin>> N1>> N2;
N1 > N2
N if (N1 > N2)
Output N2 cout<<N1<<endl;
else
cout<<N2<<endl;
End }

Course Material for CS10 Page 48 of 87Course Material for CS10


Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87Course Material for CS10
Page 48 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

2.) Create a flowchart and a c++ program that would input an integer number and then
indicate whether the number is an even or an odd number.

Course Material for CS10 Page 49 of 87Course Material for CS10


Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87Course Material for CS10
Page 49 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart

Start

Input num

Y
If Output
num % 2 == 0 A
“even number”

N
Output
“odd number”
A
End

Course Material for CS10 Page 50 of 87Course Material for CS10


Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87Course Material for CS10
Page 50 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

C++ Program

#include<iostream.h>

void main()
{ int num

cout<<” Input an integer number: ”;


cin>> num;
Course Material for CS10 Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
if (num % 2 == 0) Page 51 of 87Course Material for CS10
cout<< “ The number you’ve entered is 51
Page anofeven number”<<endl;
87Course Material for CS10
else Page 51 of 87Course Material for CS10
cout<< “ The number you’ve entered is 51
Page anofodd number”<<endl;
87Course Material for CS10
} Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87Course Material for CS10
Page 51 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

3.) Juan dela Cruz Restaurant is offering a 10% discount to all customers whose last
name is also dela Cruz. Input the last name of the customer and the total amount due to
the customer and then output the amount to be paid.

Course Material for CS10 Page 52 of 87Course Material for CS10


Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87Course Material for CS10
Page 52 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Start Flowchart

Input Lname, AmtDue

Y
If
Lname == AmtPd = AmtDue - Amtdue*0.1
“dela Cruz”

N Output “You have a 10% discount”, AmtPd

AmtPd = Amtdue

Output “You don’t have a 10% discount”, AmtPd


Course Material for CS10 Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
End
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87Course Material for CS10
Page 53 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming C++ Program

#include <iostream.h>
#include<stdio.h>
#include<string.h>

void main()
{ char Lname[40];
double AmtPd, AmtDue;

puts("Input Customer\'s Last Name : ");


gets(Lname);
cout<<"Input amount due : ";
cin>>AmtDue;
if (strcmpi(Lname, "dela Cruz")==0)
{
AmtPd = AmtDue - AmtDue *0.1;
cout<< " You are entitled to a 10% discount "<<endl;
Course Material for CS10 cout<< " Amount to bePagepaid54
= "<< AmtPd<<endl;
of 87Course Material for CS10
} Page 54 of 87Course Material for CS10
else Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
{ Page 54 of 87Course Material for CS10
AmtPd = AmtDue; Page 54 of 87Course Material for CS10
cout<< " You are not entitled
Page 54to
ofa87Course
10% discount
Material"<<endl;
for CS10
cout<< " Amount to bePage
paid54 of 87Course
= "<< Material for CS10
AmtPd<<endl;
} Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
} Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
Page 54 of 87Course Material for CS10
Page 54 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

Course Material for CS10 Page 55 of 87Course Material for CS10


Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87Course Material for CS10
Page 55 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

4.) Workers at Kookaburra Factory have a regular working hours of 30 hours per week
and are paid $ 10.00 per hour. However, if the workers rendered more than 30 hours
per week, the excess hours are paid 75% more. Create a flowchart and a c++ program
Course Material for CS10 Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87Course Material for CS10
Page 56 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
that would input the number of hours rendered by a worker in one week and output his
net salary.

Course Material for CS10 Page 57 of 87Course Material for CS10


Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87Course Material for CS10
Page 57 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart

Start

Input NHrs

N
If Salary = NHrs *10 A
NHrs > 30

Y
Salary = 300 + (NHrs – 30) * 17.50
A
Course Material for CS10 Page 58 of 87Course Material for CS10
Output Salary Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
End Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87Course Material for CS10
Page 58 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

C++ Program

#include <iostream.h>

void main()
{ double NHrs, Salary;

cout<< ” Input number of hours worked: ”;


cin>> NHrs;
if (NHrs > 30)
Salary = 300 + (NHrs – 30) * 17.50;
else
Salary = NHrs * 10.00;
cout<< “ Your salary = ”<< Salary<<endl;
}
Course Material for CS10 Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87Course Material for CS10
Page 59 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

5.) The fine for an over-speeding violation depends on the speed of the erring driver, as
follows:
121 to 150 km/h = RO 30.000
151 km/h and above = RO 50.000

Create a flowchart and a c++ program to input the car’s speed and then output
the fine, if there’s any.

6.) In the game of JACK N POY each of the two player choose either a scissors (code
X), paper (code P), or stone (code S). If one chooses scissors and the other chooses
stone then stone wins. If one chooses paper and the other stone then paper wins. If one
chooses paper and the other scissors then scissors wins. If they both choose the same
then the result is a tie. Create a flowchart or a c++ program that will input two character
codes corresponding to the object selected and then output either the message
“PLAYER 1 WINS” or “PLAYER 2 WINS”.
Course Material for CS10 Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87Course Material for CS10
Page 60 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

ITERATIVE PROGRAM STRUCTURE

1.) Create a flowchart/c++ program that will generate the following number series:
10, 5, 9, 10, 8, 15, 7, 20, 6, and 25

Course Material for CS10 Page 61 of 87Course Material for CS10


Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87Course Material for CS10
Page 61 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart C++ Program
#include<iostream.h>
Start
void main()
{ int X, Y;
X = 10 X = 10;
Y=5 Y = 5;
do
{
cout<< X<<endl<<Y<<endl;
Output X, Y
X = X – 1;
Y = Y + 5;
} while (X >= 6);
X=X–1 }
Y=Y+5

Course Material for CS10 Page 62 of 87Course Material for CS10


Page 62 of 87Course Material for CS10
Y Page 62 of 87Course Material for CS10
If Page 62 of 87Course Material for CS10
X >= 6 Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
N Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
End Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87Course Material for CS10
Page 62 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
2.) Create a flowchart/c++ program that will generate the following number series:
1, 1, 2, 3, 5, 8, 13, 21, 34, and 55

Course Material for CS10 Page 63 of 87Course Material for CS10


Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87Course Material for CS10
Page 63 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart

Start C++ Program

#include <iostream.h>
X=0
Y=1
Sum = 1 void main()
{ int X, Y, Sum;
Output Sum
X = 0;
Y = 1;
Sum = 1;
Sum = X + Y
do
X=Y
{
Y = Sum
cout<< Sum<<endl;
Sum = X + Y;
X = Y;
Course Material for CS10 Y Page 64 of 87Course
Y = Sum;Material for CS10
If Page 64 of 87Course Material for CS10
Sum <= 55 } while (Sum <= 55);
Page 64 of 87Course Material for CS10
N } Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Stop Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87Course Material for CS10
Page 64 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
3.) Create a flowchart/c++ program that will generate the following number series:
1, 2, 4, 7, 11, 16, 22, 29, 37, and 46

Course Material for CS10 Page 65 of 87Course Material for CS10


Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87Course Material for CS10
Page 65 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart C++ Program

Start #include <iostream.h>

X=1 void main()


Y=1 { int X, Y;
X = 1;
Output Y Y = 1;
do
Y=Y+X {
X=X+1 cout<< Y<<endl;
Y = Y + X;
X = X + 1;
Y } while (Y <= 46);
If
}
Y <= 46
N
Course Material
Endfor CS10 Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87Course Material for CS10
Page 66 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
4.) Create a flowchart/c++ program that will input five numbers and output how many of
the numbers entered are odd or even.

Course Material for CS10 Page 67 of 87Course Material for CS10


Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87Course Material for CS10
Page 67 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart
A
Start
ctr = ctr + 1
ctr = 1
ctre = 0
ctro = 0 Y
B If B
ctr <= 5
Accept num
N
Output ctro, ctre
Y
If ctre = ctre + 1 A
num % 2 == 0
End
N
Course Material for CS10 Page 68 of 87Course Material for CS10
ctro = ctro + 1 Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
A Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87Course Material for CS10
Page 68 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

C++ Program

#include <iostream.h>

void main()
{ int num, ctr=1, ctro=0, ctre=0;

do
{
cin>> num;
if (num % 2 == 0)
ctre = ctre + 1;
else
ctro = ctro + 1;
ctr = ctr + 1;
} while (ctr <= 5);
Course Material
cout<<for CS10
ctro<<endl<< ctre<<endl; Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
} Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87Course Material for CS10
Page 69 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

5.) Create a flowchart/c++ program that will input five numbers and output how many of
the numbers entered are positive or negative.

Course Material for CS10 Page 70 of 87Course Material for CS10


Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87Course Material for CS10
Page 70 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart
A
Start
ctr = ctr + 1
ctr = 1
ctrp = 0
ctrn = 0 Y
B If B
ctr <= 5
Accept num
N
Output ctrp, ctrn
Y
If ctrp = ctrp + 1 A
num > 0
End
N
Course Material for CS10 Page 71 of 87Course Material for CS10
ctrn = ctrn + 1 Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
A Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87Course Material for CS10
Page 71 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

C++ Program

#include <iostream.h>

void main()
{ int num, ctr=1, ctrp=0, ctrn=0;

do
{
cin>> num;
if (num > 0)
ctrp = ctrp + 1;
else
ctrn = ctrn + 1;
ctr = ctr + 1;
} while (ctr <= 5);
Course Material for CS10
cout<<ctrp<<endl<<ctrn<<endl; Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
} Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87Course Material for CS10
Page 72 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

6.) Create a flowchart/c++ program that will input 10 alphabetic characters and output
how many of the characters entered were vowels and consonants. Disregard characters
that are not alphabetic.
7.) Create a flowchart/ c++ program that will input 5 numbers and output the highest
number entered.
8.) Create a flowchart/ c++ program that will input 6 score for quizzes (0-100). Eliminate
the lowest quiz and compute and output the average of the five remaining quizzes.

ARRAYS

ARRAYS - a series of simple variables grouped together under one single variable.

int Score[5];
Course Material for CS10 Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87Course Material for CS10
Page 73 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

In the computer’s main memory, this can be depicted as:

Score[0] Score[1] Score[2] Score[3] Score[4]

Notice that a total of 5 adjacent slots are allotted because the array is declared as size 5.
In effect, array SCORE can hold 5 different values at the same time.

There are certain rules to follow when using subscripts and they are as follows:

1 The value of the subscript must be a positive integer number.


2 It can be an integer constant (e.g., Score[2]), numeric variable with integer
value (e. g., Score[X] where X is a numeric variable with integer value)
3 The first element always has a subscript of 0.
Course Material for CS10 Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87Course Material for CS10
Page 74 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
4 The value of the subscript cannot exceed the size of the array minus 1. For
example, for array Score, the subscript must be between 0 and 4 only since Score was
declared as Score[5].
5 The subscript must be enclosed in square bracket.

Examples of Incorrect usage of subscript:

Consider the variable declaration below:

int TOTAL[12], IND;


char XX[20];

1.) TOTAL [0.1]


2.) TOTAL [-1]
3.) TOTAL [14]

* Subscript must be between 0 and the size of the array minus 1 which in this case
12.
Course Material for CS10 Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87Course Material for CS10
Page 75 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

2.) TOTAL {2}

* Subscript must be enclosed within square bracket. No other symbols must be


used.

3.) TOTAL [XX]

* Subscript must be either an integer constant, numeric variable with integer value
or an arithmetic expression with integer value or an arithmetic expression with
integer result. The above is a character array variable which violates the rule just
mentioned.

4.) TOTAL [“2”]

* Subscript must be numeric.

5.) TOTAL [5+10]


Course Material for CS10 Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87Course Material for CS10
Page 76 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

* The resulting answer of 15 exceeds the size of the array which was defined as
TOTAL is ARRAY [12]

Assigning values to an array element using assignment statement:

To assign number 10 to element number 0, the statement is:

Score[0] = 10;

To assign number 20 + 30 to element number 1, the statement is:

Score[1] = 20 + 30;

To assign expression X / 5 to element number 3, the statement is:

Score[3] = X / 5;
Course Material for CS10 Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87Course Material for CS10
Page 77 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

To assign the content of variable X to element number 4, the statement is:

Score[4] = X;

To assign the content of element number 4 to element number 3, the statement is:

Score[3] = Score[4]

To assign the result of multiplying the content of element number 4 to element number 2
and putting the result in element number 1, the statement is:

Score[1] = Score[5] * Score[3]

To assign zero to all the elements of array Score, the statement is:

ctr = 0;
Course Material for CS10 Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87Course Material for CS10
Page 78 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
while (ctr<5)
{
Score(ctr) = 0;
ctr = ctr + 1;
}

1.) Create a flowchart/c++ program that would accept 10 numbers and then display
all 10 numbers together with its total.

Course Material for CS10 Page 79 of 87Course Material for CS10


Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87Course Material for CS10
Page 79 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart
A
Start Flowchart

ctr = 0 ctr = 0
sum = 0

Output NUM(ctr)
Input NUM(ctr)

ctr = ctr + 1 ctr = ctr + 1


sum = sum + NUM(ctr)

Y
If
Y ctr <10
If
ctr < 10 N
Course Material for CS10 Page 80 of 87Course Material for CS10
N Page 80 of
Output sum87Course Material for CS10
Page 80 of 87Course Material for CS10
A Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
PageEnd
80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87Course Material for CS10
Page 80 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

Course Material for CS10 Page 81 of 87Course Material for CS10


Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87Course Material for CS10
Page 81 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals C++ Program
and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
#include <iostream.h>Fundamentals and ProgrammingComputer
ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
void main()
Programming
{ int NUM[10];
int ctr=0, sum=0;
do
{
cin>> NUM[ctr];
sum = sum + NUM[ctr];
ctr = ctr + 1;
} while (ctr <10);
ctr =0;
do
{
cout<< NUM[ctr];
ctr = ctr + 1;
} while (ctr < 10);
cout<<“The total of all the numbers entered = “<<sum<<endl;
}

Course Material for CS10 Page 82 of 87Course Material for CS10


Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87Course Material for CS10
Page 82 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
2.) Create a flowchart/c++ program that would assign numbers 8-15 to an array of 8
elements. The program must then display the contents of the array starting from
the last element.

Course Material for CS10 Page 83 of 87Course Material for CS10


Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87Course Material for CS10
Page 83 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
Flowchart
A

Start
ctr = 7

ctr = 0
value = 8 Output NUM(ctr)

NUM(ctr) = value
value = value + 1 ctr = ctr - 1
ctr = ctr + 1

Y
Y If
If ctr >= 0
ctr <= 7
N
Course Material for CS10 N
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
A End
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87Course Material for CS10
Page 84 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming

Course Material for CS10 Page 85 of 87Course Material for CS10


Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87Course Material for CS10
Page 85 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
C++ Program
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
#include <iostream.h>
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
void main()
ProgrammingComputer Fundamentals and ProgrammingComputer
{ int NUM[8];
Fundamentals and ProgrammingComputer Fundamentals and
Int ctr=0, value=8;
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
do
ProgrammingComputer Fundamentals and ProgrammingComputer
{
Fundamentals and ProgrammingComputer Fundamentals and
NUM[ctr] = value;
ProgrammingComputer Fundamentals and ProgrammingComputer
value = value + 1;
Fundamentals and ProgrammingComputer Fundamentals and
ctr = ctr + 1;
ProgrammingComputer Fundamentals and ProgrammingComputer
} while (ctr <=7);
Fundamentals and ProgrammingComputer Fundamentals and
Programming
ctr=7;
do
{
cout<< NUM[ctr];
ctr = ctr – 1;
} while (ctr >= 0);
}

Exercises:

1.) Create a flowchart and a c++ program that will declare an array named A with 10
elements. Prompt the user to input values into its first five cells and copy the
numbers entered into its last five cells. Finally, output the content of array A.

2.) Create a flowchart and a c++ program that will input values to array A[10] and
array B[10]. Exchange their values in reverse order and output the new content
of arrays A and B.

Course Material for CS10 Page 86 of 87Course Material for CS10


Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87Course Material for CS10
Page 86 of 87
Computer Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
ProgrammingComputer Fundamentals and ProgrammingComputer
Fundamentals and ProgrammingComputer Fundamentals and
Programming
3.) Create a flowchart and a c++ program that will declare an array named NUM with
10 elements. Compute its product such that all the elements in the odd
subscripts will be your multiplicand and all the elements in the even subscript will
be your multiplier. Placed the product into the array named PROD with 5
elements and finally output the content of array PROD.

4.) Create a flowchart and a c++ program that will prompt the user to input numbers
into array C and the input should be terminated by a zero sentinel. Output the
contents of array C and also the highest and the lowest number entered.

Course Material for CS10 Page 87 of 87Course Material for CS10


Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87Course Material for CS10
Page 87 of 87

You might also like