Sunday, January 18, 2009

ARRAYS.
by: mary trishia v. tabigue

Most programming languages have a built-in array data type, although what is called an array in the language documentation is sometimes really an associative array. Conversely, the contiguous storage kind of array discussed here may alternatively be called a vector, list or table.
Some programming languages support array programming (e.g., APL, newer versions of Fortran) which generalises operations and functions to work transparently over arrays as they do with scalars, instead of requiring looping over array members.
Multi-dimensional arrays are accessed using more than one index: one for each dimension. Multidimensional indexing reduced to a lesser number of dimensions, for example, a two-dimensional array with consisting of 6 and 5 elements respectively could be represented using a one-dimensional array of 30 elements.
Arrays can be classified as fixed-sized arrays (sometimes known as static arrays) whose size cannot change once their storage has been allocated, or
dynamic arrays, which can be resized.
RECURSIONS.
by: mary trishia v. tabigue
An essential ingredient of recursion is there must be a "termination condition"; i.e. the call to oneself must be conditional to some test or predicate condition which will cease the recursive calling. A recursive program must cease the recursion o n some condition or be in a circular state, i.e. an endless loop which will "crash" the system.
In a computer implementation of a recursive algorithm, a function will conditionally call itself. When any function call is performed, a new complete copy of the function's "information" (parameters, return addresses, etc.. ) is placed into general dat a and/or stack memory. When a function returns or exits, this information is returned to the free memory pool and the function ceases to actively exist. In recursive algorithms, many levels of function calls can be initiated resulting in many copies of th e function being currently active and copies of the different functions information residing in the memory spaces. Thus recursion provides no savings in storage nor will it be faster than a good non-recursive implementation. However, recursive code will o ften be more compact, easier to design, develop, implement, integrate, test, and debug.
ITERATIVE STATEMENTS.*
by: mary trishia v. tabigue
Iterative statements repeated execution of list of statements, depending on the value of a boolean expression.
Syntax:
while ( ) {
}
As long as the boolean expression is true, the statement list is executed repeatedly.
When the boolean expression is false, the statement list is skipped, and execution continues with the statement following the while statement.
Style: The statement list should be indented.
example:
#include
using namespace std;
int main () {
int Entry;
int Counter;
cout << "Enter a positive integer: ";
cin >> Entry;
Counter = 1;
while (Counter <= Entry) {
cout << "Iteration " <<>
Counter = Counter + 1;
}
return 0;
}
Program output:
>iterative
Enter a positive integer: 4
Iteration 1 of 4
Iteration 2 of 4
Iteration 3 of 4
Iteration 4 of 4

X'MAS. :)
by: mary trishia v. tabigue
I LOVE HOLIDAYS SO MUCH.!
hehe. :)
a pause. a break.
oye.! I'm gonna enjoy this time not minding programming issues.
hehe.
I'd settle with those later. :)
CONDITIONAL STATEMENTS..
BY: MARY TRISHIA V. TABIGUE
. conditional statements, conditional expressions and conditional constructs are features of a programming language which perform different computations or actions depending on whether a programmer-specified condition evaluates to true or false
if...else Statement
Use the if statement to execute a statement if a logical condition is true. Use the optional elseif statement looks as follows: clause to execute a statement if the condition is false. An
if
(condition)
statement_1
[else
statement_2]
If condition evaluates to true, statement_1 is executed; otherwise, statement_2 is executed. statement_1 and statement_2 can be any statement, including further nested if statements.
You may also compound the statements using else if to have multiple conditions tested in sequence;
if (condition)
statement_1
[else if (condition_2)
statement_2]
..
[else if (condition_n_1)
statement_n_1]
[else
statement_n]
To execute multiple statements, use a block statement ({ ... }) to group those statements. In general, it is a good practice to always use block statements, especially in code involving nested if statements:
if (condition) {
statements_1
} else {
statements_2
}
switch Statement
A switch statement allows a program to evaluate an expression and attempt to match the expression's value to a case label. If a match is found, the program executes the associated statement. A switch statement looks as follows:
switch
(expression) {
case label_1:
statements_1
[break;]
case label_2:
statements_2
[break;]
...
default:
statements_def
[break;]
}
The optional break statement associated with each case clause ensures that the program breaks out of switch once the matched statement is executed and continues execution at the statement following switch. If break is omitted, the program continues execution at the next statement in the switch statement.
AGAIN.?! YEHEY.!!
by: mary trishia v. tabigue
I thought we will have a hard-time class today. :)
But I guess LUCK is with US.!!
We didn't have classes in Computer Programming because Sir Ernie is one of the teachers that will perform for the upcoming TEACHER's DAY. ^^
But still, we had our reportings in our assignments. :)
Still, we had enough knowledge for those problems, especially in answering them. :)
I LOVE THIS WEEK.!
by: mary trishia v. tabigue
I love this week.! because we have no regular classes. (yey.!)
Teachers and Students are so much busy preparing for the Regional Press Conference that will be held in our school.
But this will not last long. :(
(how sad)
Next week will be a challenging week I suppose.
Classes will resume and mid-boggling subjects will be ON again.