Thursday, July 9, 2009

Lectures in PGS Programming

Computer Programming
Loops and Iterations

Fundamentals of Looping
• Iteration – The repetition of the loop.

When the given problem says that we are to print the numbers 1 to 10, this would mean that we will need a repetition of instruction PRINT 10 times. The number or repetitions the loop has taken to perform to satisfy the problem is the number of iterations.

• Accumulator – a temporary storage location in a central processing unit that holds values during a process.

• Counter – a temporary storage location that counts the number of iteration/process in a program.

Types of Loops
• Infinite Loop – A loop that runs without end. It is due to mistakes in the logical operation or expression or variables used to control the termination of the loop.Others call this logical error. Often this type of error is hardest type to debug.

• Index Loop – A loop that executes when the number of iteration is explicit in the problem. The printing of the 1 to 10 is an example of this type of loop.

• Conditional Loop – A loop that executes only in a given satisfied condition. The number of iterations in this type of loop is not in the problem and the iteration is dependent on the conditions given. Decision Symbol is used as a loop terminator in the Conditional loop.

o Pre-condition Approach
It is a conditional loop that checks the condition first before the instruction is executed. A classic looping constructs under this type of approach is the While Loop. This loop checks if the condition given in the decision symbol is true. If it is true, the program performs the instruction. The rule thumb for this approach in programming is:

“While the condition is true, Do *statement/s”
*Statements may be a single instruction (e.g., c = c+1 ) or series of instructions (e.g., j =j+1;, followed by x =x*j, and print (x)).

o Post-condition Approach
It is a conditional loop that executes the instructions first before checking the condition. A classic looping construct this type of approach is the Do While Loop. The Do While Loop performs the instruction before checking the condition given in the decision symbol. In addition, do while loop performs the instruction at least once if the condition set in the decision symbol is not true. The loop continues while the condition is true. The rule of thumb in programming under this approach is :

“Always executes its loop at least once.”
“Do statement and iterates while the condition is true”

Exercises:
1.Accept a number and print the product of the integers. Use pre-condition approach.
2.Accept a number and print the integers and the sum of the integers of the number. Use pre-condition approach.
3.Use post-condition approach to the problem in number 1.
4.Use post-condition approach to the problem in number 2.

actitivy no. 3 for Programming

Computer Programming: Design Program Logic
Decision Application

Create a flowchart and write the program of the following problems. Draw the flowchart on a short bond paper.

1.Accept two integers and determine if the values are equal, if the values are equal do not print anything, otherwise print the higher number.
2.Input three unique numbers and print the lowest number.
3.Input three unique numbers and print the difference of the highest and lowest numbers.
4.Create a flowchart that will accept a child’s age and print its equivalent education level. The age of a chil is considered 1 year old if it reaches 6 months. Given the condition of converting 6 months to a1 year, the flowchart should be able to identify the child’s education level. If a child was able to finish college, it is considered that he is not longer a child and is already a young adult and a professional. If the educational level is professional, the flowchart should not print anything. The education level in relation to the age is as follows:

Age 0 – 2 - Parental Age 7 – 12 - Elementary
Age 3 – 4 - Nursery Age 13 – 16 - Highschool
Age 5 – 6 - Pre-school Age 17 – 21 - College

Activity no. 2 for Programming

Computer Programming
Input-Output and Process Application

Create a flowchart and write the program of the following problems. Draw the flowchart on a short bond paper.

1.Accept three numbers and print the sum of the inputted numbers.
2.Accept three numbers and print the product of the inputted numbers.
3.Create a flowchart that will accept three numbers and prints the sum, product and average of the numbers.
4.Accept a dollar value and print the equivalent peso value. The flowchart will convert dollar peso having an exchange rate of 1 is to 47.50.
5.Create a flowchart that will accept two integers. If the integers are equal, print the sum of the integers, otherwise print the product.
6.Create a flowchart that will input unique integers for A, B, and C and print the highest number.

PGS Activities in Proggramming

Programming NC IV
Computer Laboratory Exercises:

Instructions: create a flowchart and pseudocode of the following programs aside from coding this to your c++ language. Indicate your name as a programmer and the exercise # in every program.
The pseudocode and program will be placed in a short bond paper.

1.Create a program that will display your name.
2.Create a program that will accept your name and after inputting your name, it will appear Good morning!
3.Create a program that will accept five integers and will display the average of the five.
4.Create a program that will compare two integers and will display what is lower.
5.Create a program that will accept two integers and compare which is higher.

Thursday, February 12, 2009

TMTP and CAC Seminar


These photos are taken during the TMTP ( trainer's methodology training program) and CAC (competency assessors course) Seminar that was held at UCC (Union Christian College), San Fernando City, La Union, from february 2-6, and february 9-11.