Sunday, January 18, 2009
Saturday, January 17, 2009
ArrAys..
This week we had a short discussion of arrays.
*ARRAYS-it is a collection of variables of the same data type that is referenced by a common name.
The general form for an array declaration is as follows:
type array_name[size];
Where:
*type is any valid data type in Turbo C which declares the type of values that array will hold. *array_name is a valid variable name which will name the array.
*size defines how many elements the array will hold.
->Arrays can give initial values during the declaration.This is called array initialization.
int Array1[5]={25,5,7,11,163};
And by the way...we had already taken our third periodical exam..That's all!
Tuesday, January 13, 2009
Learnings of the Week (ROLLORATA)
- An array is a variable name that is associated with a number of adjacent locations in RAM.
- If the name of the variable is, for example, StudentQuizScores, individual values within the array are accessed via an array index, or just index using a syntax something like:
StudentQuizScores[i]
which means the i-th element/value in the array "StudentQuizScores". - The array name plus index notation is treated just like a regular variable in the programming syntax. E.g.,
StudentQuizScores[i] = StudentQuizScores[i] + Quiz4Score;
- Depending on the particular programming language, the index associated with the very first element in an array might have the value 1 or 0 (most modern ones use 0).
Saturday, January 10, 2009
Recursion
BY: Sharra Mae S. Tagaro IV- Rizal
This week, we had a brief discussion of recursion:
*RECURSION- defined as the repetitive process by which a function calls itself. It is also termed as the CIRCULAR DEFINITION. Recursion is also a programming technique where a routine performs its task by delegating part of it to another instance of itself.
For example in this program segment:
Factorial (int n)
{
If (n==1||n==0) return 1;
else return (n * factorial (n-1));
}
In this program segment, it illustrates a function containing a call to it. The lines else return (n * factorial (n-1)); contains the function call for the factorial function.
The parts of the recursive function include the Base Case. The base case can be found in the “if clause”. It contains the condition that should be satisfied at one point of execution to terminate the repetitive process done be the recursive function. And the other part of the recursive function is the General Case. The general case can be located on the “else-clause”. It contains the function call of the recursive function to itself.
The Direct Recursion is a recursive functions that can call itself through a function call directly inside the body of the function. While the second type of recursion is the indirect recursion. The Indirect Recursion is a recursive functions that can call another function outside its function.
And we had an activity in programming about it...that's all!^-^,.
Learnings of the Week (ROLLORATA)
Monday, January 5, 2009
Learnings of the Week (ROLLORATA)
Three types of iterative statement are provided: the for-statement providing definite iteration and the while- and repeat-statements providing indefinite iteration.
Iteration may be performed over an arithmetic progression of integers or over any finite enumerated structure. Iterative statements may be nested. If nested iterations occur over the same enumerated structure, abbreviations such as for x, y in X do may be used; the leftmost identifier will correspond to the outermost loop, etc.
Early termination of the body of loop may be specified through use of the `jump' commands breakcontinue. and
Definite Iteration
for i := expr_1 to expr_2 by expr_3 do : ->
The expressions in this for loop must return integer values, say b, e and s (for `begin', `end' and `step') respectively. The loop is ignored if either s>0 and b>e, or s<0 s="0" k="0,">0) or b + k.s>e (for e<0).>If the required step size is 1, the above may be abbreviated to:
for i := expr_1 to expr_2 do : ->
for x in S do : ->
Each of the elements of the finite enumerated structure S will be assigned to x in succession, and each time the statements will be executed.
Indefinite Iteration
while boolexpr do statements end while : ->
Check whether or not the Boolean expression has the value {true}; if it has, execute the statements. Repeat this until the expression assumes the value {false}, in which case statements following the end while; will be executed.
