Wednesday, October 2, 2013

Saturday, January 24, 2009

4th LEARNINGS OF THE WEEK 1 -Caligdong

HTML

HTML stands for Hyper Text Markup Language.An HTML file consists of small markup tags which tells the web browser hot to display the page. It is indicated by an "htm" or "html" file extension. it is created through notepad or other simple text editor applications.

The most important tags in HTML are those that define headings, paragraphs, and line breaks.
Here are list of some common tags:

TAG DESCRIPTION
< html > Defines an HTML document
< body > Defines the document's body
< h1 > to < h6 > Defines header 1 to 6

Defines a paragraph
< br / > Inserts a single line break
< hr / > Defines a horizontal rule
< !- - > Defines a comment
%nbsp; Adds one space
*tags for html text formatting*
defines inserted text
defines deleted text

Some characters like the <>

A character entity has three parts: an ampersand (&), an entity name or a # and an entity number, and finally a semicolon (;).

The less than sign must be written in this way:
&It; or <.

The advantage of using a name instead of a number is that a name is very easy to remember.
Here are the list of some common character entities:

result entity name entity number
< &It  
> > <
& & &
" &qout; "
' ' '
x × ×

÷ ÷ ÷


Friday, January 23, 2009

Learnings of the Week (CAMAY)

We had a lesson this week but we weren't able to discuss it.

It's all about ARRAYS. Array is a collection of variables of the same data type that is referenced by a common name.

EXAMPLE:

#include
main()
{
int array[4]={25,5,7,11,163};
clrscr();
printf(“%d %d %d %d %d”, array[0], array[1], array[2],array[3],array[4]);
getch();
}

THE OUTPUT FOR THE EXAMPLE IS:

25 5 7 11 163


PARTS OF ARRAY

Array[0] = 25

"Array" is called the array name.
"[0]" is the subscript or index.
"25" is the array element.


* The general form for any 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. It defines how many elements the array will hold.


* The two declarations for arrays number and answer can be combined into a single declaration:

int number[100] , answer [25]


Arrays can give initial values during the declaration. This is called array initialization..

int Array1[5]={25, 5, 7, 11, 163}

Learnings of the Week (CAMAY)

LOOPING


Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met. It can be predefined as in the loop, or open ended as in while and do-while.


The types of iterative statements are:

1. The For statements

2. The While statements

3. The Do-While statements


The For statement or for loop is considered as a predefined loop because the number or times it iterates to perform its body is predetermined in the loop’s definition.

The For loop contains a counter whose values determine the number of times the loop iterates. The iteration stops upon reaching the number of times specified in the loop.


The general form of the for statement is:

for (initialization; condition; increment)
{
statement_sequence;
}

Where:
--->for is a reserve word in C

--->initialization is an assignment statement that is used to set the loop’s counter.

--->condition is a relational boolean expression that determines when the loop will exit.

--->increment defines how the loop’s counter will change each time the loop is separated.

--->statement sequence may either be a single C statement or a block of C statements that make up the loop body.


~> The for loop continues to execute until the condition is True (1).
~> Once False (0), program execution resumes on the statement following the for loop.
~> Note:
a. Never place a semicolon right after the for header.

b. Never change the value of the for loop’s counter in side the body of the loop. This will affect the result of the program.

c. The increment part of the for loop is execute after the first iteration of the loop.


Example:
Write a program that will print the numbers 1 to 10 using a for statement.
#include
int x;
main()
{
for (x=1; x<=10; x++)
printf (“%d\n”,x);
getch();
}


[the output for this example is:]

1
2
3
4
5
6
7
8
9
10


----> The while statement or while loop is an open-ended or event-controlled loop.
The while loop iterates while the condition is TRUE (1).
When it becomes FALSE (0), the program control passes to the line after the loop code.

The general form of the while statement is:

while (condition)
{
statement_sequence;
}

where:
~> While is a reserved word in C

~> Condition is a relational expression that determines when the loop will exit.

~> Statement_sequence may either be a single C statement or a block of C statements that make up the loop body.


The second type of open-ended or event-controlled loop is the do-while statement or do-while loop.
The general form of the do-while statement is:
do
{
statement_sequence;
} while (condition);


~> Do-While is a variation of the while statement which checks the condition at the bottom / end of the loop.

~> This means that a do-while loop “always executes at least once”.

~> In the do-while loop, when the condition evaluates to TRUE (1), the loop body will be executed, but when FALSE (0), program control proceeds to the next instruction after the do-while loop.

Monday, January 19, 2009

3rd-learnings of the week(Colegado)

In computer science, an array is a data structure consisting of a group of elements that are accessed by indexing. In most programming languages each element has the same data type and the array occupies a contiguous area of storage.
Arrays permit constant time (O(1)) random access to individual elements, which is optimal, but moving elements requires time proportional to the number of elements moved. On actual hardware, the presence of e.g. caches can make sequential iteration over an array noticeably faster than random access — a consequence of arrays having good locality of reference because their elements occupy contiguous memory locations — but this does not change the asymptotic complexity of access. Likewise, there are often facilities (such as memcpy) which can be used to move contiguous blocks of array elements faster than one can do through individual element access, but that does not change the asymptotic complexity either.

Memory-wise, arrays are compact data structures with no per-element overhead. There may be a per-array overhead, e.g. to store index bounds, but this is language-dependent. It can also happen that elements stored in an array require less memory than the same elements stored in individual variables, because several array elements can be stored in a single word; such arrays are often called packed arrays.

Array is a collection of variables of the same data type that is referenced by a common name. The two declarations for arrays number and answer can be combined into a single declaration:
int number[100] , answer [25];
Arrays can give initial values during the declaration. This is called array initialization..
int Array1[5]={25, 5, 7, 11, 163};

The general form for any 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.

3rd-learnings of the week(Colegado)

RECURSION

The repetitive process by which a functions calls itself is called recursion or circular definition. This is a way of defining something in terms of itself. A function is said to be recursive if a statement in the body of the function calls the function that contains it.


Base Case. This is the part of the recursive function that is found on the if clause. This contains the condition that should be satisfied at one point of execution to terminate the repetitive process done by the recursive function.
General Case. This is the part of the recursive function that is found on the else-clause. This contains the function call of the recursive function to itself.

Give the output of the ff. program when the value entered for a=5.
#include
main()
{
int a, b;
clrscr();
printf(“Enter a value:”);
scanf(“%d”, &a);
b= solve (a);
printf(“The new value is %d”, b);
getch();

solve (int a)
{
if (a == 1) return 2;
else return (solve (a-1) + 2);
}


The output is:

Enter a value: 5
The new value is 10.

Direct and Indirect Recursion

Direct recursions are recursive functions that can call itself through a function call directly inside the body of the function. Indirect recursions are recursive functions that can call another functions outside its function.

A common method of simplification is to divide a problem into subproblems of the same type. As a computer programming technique, this is called divide and conquer and is key to the design of many important algorithms, as well as being a fundamental part of dynamic programming.

Recursion in computer programming is exemplified when a function is defined in terms of itself. One example application of recursion is in parsers for programming languages. The great advantage of recursion is that an infinite set of possible sentences, designs or other data can be defined, parsed or produced by a finite computer program.

Recurrence relations are equations to define one or more sequences recursively. Some specific kinds of recurrence relation can be "solved" to obtain a non-recursive definition.

A classic example of recursion is the definition of the factorial function, given here in C code:

unsigned int factorial(unsigned int n)
{
if (n <= 1) return 1;
return n * factorial(n-1);
}

The function calls itself recursively on a smaller version of the input (n - 1) and multiplies the result of the recursive call by n, until reaching the base case, analogously to the mathematical definition of factorial.

Use of recursion in an algorithm has both advantages and disadvantages. The main advantage is usually simplicity. The main disadvantage is often that the algorithm may require large amounts of memory if the depth of the recursion is very large. It has been claimed that recursive algorithms are easier to understand because the code is shorter and is closer to a mathematical definition, as seen in these factorial examples.

It is often possible to replace a recursive call with a simple loop, as the following example of factorial shows:

unsigned int factorial(unsigned int n) {
if (n <= 1) return 1;
unsigned int result = n;
while (--n) result *= n;
return result;
}

It should be noted that on most CPUs the above examples give correct results only for small values of n, due to arithmetic overflow.

An example of a recursive algorithm is a procedure that processes (does something with) all the nodes of a tree data structure:

void ProcessTree(node x) {
unsigned int i = 0;
while (i < x.count) {
ProcessTree(x.children[i]);
i++;
}
ProcessNode(x); // now perform the operation with the node itself
}

To process the whole tree, the procedure is called with a root node representing the tree as an initial parameter. The procedure calls itself recursively on all child nodes of the given node (i.e. sub-trees of the given tree), until reaching the base case that is a node with no child nodes (i.e. a tree having no branches known as a "leaf").

A tree data structure itself can be defined recursively (and so predestinated for recursive processing) like this:

typedef struct {
unsigned int count;
node* children;
} node

Saturday, January 17, 2009

Learnings of the Week (CAMAY)

RECURSION

The repetitive process by which a functions calls itself is called recursion or circular definition. This is a way of defining something in terms of itself. A function is said to be recursive if a statement in the body of the function calls the function that contains it.


Base Case. This is the part of the recursive function that is found on the if clause. This contains the condition that should be satisfied at one point of execution to terminate the repetitive process done by the recursive function.
General Case. This is the part of the recursive function that is found on the else-clause. This contains the function call of the recursive function to itself.

Give the output of the ff. program when the value entered for a=5.
#include
main()
{
int a, b;
clrscr();
printf(“Enter a value:”);
scanf(“%d”, &a);
b= solve (a);
printf(“The new value is %d”, b);
getch();

solve (int a)
{
if (a == 1) return 2;
else return (solve (a-1) + 2);
}



The output is:


Enter a value: 5
The new value is 10.



Direct and Indirect Recursion

Direct recursions are recursive functions that can call itself through a function call directly inside the body of the function. Indirect recursions are recursive functions that can call another functions outside its function.

Friday, January 16, 2009

3rd-Learnings of the Week 7 [Caligdong]

The last chapter is all about array.

Array is a collection of variables of the same data type that is referenced by a common name. The two declarations for arrays number and answer can be combined into a single declaration:
int number[100] , answer [25];
Arrays can give initial values during the declaration. This is called array initialization..
int Array1[5]={25, 5, 7, 11, 163};

The general form for any 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.

Thursday, January 15, 2009

3rd- Learnings of the Week 6 [Caligdong]

SAMPLE PROBLEMS:

EXAMPLE 1 (INDIRECT RECURSION)
Give the output of the ff. program when the value entered for a=5.

#include
main()
{
int a, b; clrscr();
printf(“Enter a value:”); scanf(“%d”, &a);
b= solve (a); printf(“The new value is %d”, b);
getch();
}

solve (int a)
{
int b;
if ( a==1)
{
b=2; printf (“%d” , b); return b;
}
else {
b=solve2 (a-1) + 2;
printf (“%d”, b);
return b;
} }
solve2 (int a)
{
int b;
if (a == 1)
{
b=2;
printf (“%d”, b);
return b;
}
else
{
b=solve (a-1) +2;
printf (“%d “, b);
return b;
}


SAMPLE RUN(EXAMPLE 1):

Enter a value:5
2 4 6 8 10


By tracing the program when a=5…

a=5, solve2 (5-1) + 2 general case
a=4, solve (4-1) + 2 general case
a=3, solve2 (3-1) + 2 general case
a=2, solve (2-1) + 2 general case
a=1 2 base case

By simplifying the program when a=5…

a=5, solve2 (5-1) + 2 = 10 general case
a=4, solve (4-1) + 2 = 8 general case
a=3, solve2 (3-1) + 2 = 6 general case
a=2, solve (2-1) + 2 = 4 general case
a=1 2 base case

Therefore, when a=5 the values 2 4 6 8 10 will be printed on screen.



EXAMPLE 2(PASS BY VALUE):
Example:
#include
main()
{
clrscr();
x=10;
y=5;
printf(“%d %d\n”, x,y);
pass (&x,&y);
printf(“%d %d\n”,x,y);
getch();
}
pass (int *a, int *b)
{ *a=*a+5;
*b=*b*2;
printf(“%d %d \n”,*a,*b);}

Sample Output:

10 5
15 10
15 10

Thursday, December 18, 2008

3rd-Learnings of the Week 5 [Caligdong]

The eleventh chapter is all about recursion. The repetitive process by which a functions calls itself is called recursion or circular definition. This is a way of defining something in terms of itself. A function is said to be recursive if a statement in the body of the function calls the function that contains it.

Base Case is the part of the recursive function that is found on the if clause. This contains the condition that should be satisfied at one point of execution to terminate the repetitive process done by the recursive function. General Case is the part of the recursive function that is found on the else-clause. This contains the function call of the recursive function to itself.

Direct recursions are recursive functions that can call itself through a function call directly inside the body of the function. Indirect recursions are recursive functions that can call another functions outside its function.


example for recursion:
Give the output of the ff. program when the value entered for a=5.

#include
main()
{
int a, b;
clrscr();
printf(“Enter a value:”);
scanf(“%d”, &a);
b= solve (a);
printf(“The new value is %d”, b);
getch();
}
solve (int a)
{ if (a == 1) return 2;
else return (solve (a-1) + 2);
}

OUTPUT

Enter a value: 5
The new value is 10.

Wednesday, December 17, 2008

3rd-Learnings of the Week 4 [Caligdong]

We have also discussed about iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met. It can be predefined as in the loop, or open ended as in while and do-while. There are three types of Iterative statements: (1) The For statements ,(2)The While statements (3)The Do-While statements.

We must also be aware of the following when using for statements. The For statement or for loop is considered as a predefined loop because the number or times it iterates to perform its body is predetermined in the loop’s definition. The For loop contains a counter whose values determine the number of times the loop iterates. The iteration stops upon reaching the number of times specified in the loop. Never place a semicolon right after the for header. Never change the value of the for loop’s counter in side the body of the loop. This will affect the result of the program. The increment part of the for loop is execute after the first iteration of the loop.

The while statement or while loop is an open-ended or event-controlled loop. The second type of open-ended or event-controlled loop is the do-while statement or do-while loopDo-While is a variation of the while statement which checks the condition at the bottom / end of the loop.This means that a do-while loop “always executes at least once”. In the do-while loop, when the condition evaluates to TRUE (1), the loop body will be executed, but when FALSE (0), program control proceeds to the next instruction after the do-while loop.

General forms:
FOR STATEMENT

for (initialization; condition; increment)
{
statement_sequence;
}

WHILE STATEMENT
while (condition)
{
statement_sequence;
}

DO-WHILE STATEMENT
do
{
statement_sequence;
} while (condition);

Saturday, December 6, 2008

3rd-Learnings of the Week 3 [Caligdong]

false false false MicrosoftInternetExplorer4 we have discussed about the functions and structured programming of chapter 10.
  • A c program is composed of at least one function definition, that is the main() function.
  • Execution of the program begins with main() and also ends with the main() function.
  • However, a C program can also be composed of other functions aside from the main().
  • The c program presented in previous slide is composed of 3 functions: the main function, the function greet1 and the function greet2.
  • Therefore we can say that we can create a program that is composed of other function aside from the main function.
  • Note: The main( ) function should always be present in every C program.
  • The c program presented in previous slide is composed of 3 functions: the main function, the function greet1 and the function greet2.
  • Therefore we can say that we can create a program that is composed of other function aside from the main function.
  • Note: The main( ) function should always be present in every C program.

FUNCTIONS

  • Functions are the building blocks of C in which all program activity occurs.
  • A function is also called a subprogram or subroutine. It is a part of a C program that performs a task, operation or computation then may return to the calling part of the program.
  • Other functions aside from the main( ) can only be executed by the program through a “function call”.
  • Note: Function call is a C statement that is used to call a function to execute C statements found inside the function body.
  • Going back to the example, greet1( ); is an example of a function call, calling the function greet ( ).
  • main ------clrscr------printf
greet1( ) function call------greet1( ) function greet2 function call----greet2( ) function getch( )

GENERAL FORM OF A FUNCTION

function_type function_name (parameters list)

{

body of the function;

}

Where

  • function_type specifies the type of value that the function will return.
  • function_name is any valid identifier name which will name the function.
  • Parameter list is a comma separated list of variables that receive the values when the function is called.
  • body of the function is composed of valid c statements that the function will execute.

ACTUAL PARAMETERS

  • Actual Parameters are the variables found in the function call whose values will be passed to the formal parameters of the called function.
  • Formal Parameters are the variables found in the function header that will receive from the actual parameters.

CALL BY VALUE AND PASS BY VALUE

  • In the method call by value, the values of the actual parameters are passed to the formal parameters.

CALL BY VALUE

  • In the method call by value, the values of the actual parameters are passed to the formal parameters.
  • Changes that happen to the values of the formal parameters inside the function will not affect the values of the actual parameters.

PASS BY VALUE OR CALL BY REFERENCE

  • The actual parameters also pass their value to the formal parameters.
  • But the changes that happen to the values of the formal parameters inside the function will affect the values of the actual parameters.
  • This is because the actual address of the variables is passed using the address of operator (&) together with the pointer operator (*).

#include

  • sqrt(x)
  • fabs(x) - calculates the absolute value of a number
  • ceil(x) - ceil (11.25)=12
  • floor(x) - floor(11.25)=11
  • sin(x)
  • cos(x)
  • tan(x)
  • pow(x,y)

Friday, November 21, 2008

3rd-Learnings of the Week 2 [Caligdong]

We have already discussed the eighth chapter which is the conditional statements. I learned that conditional statements are statements that check an expression then may or may not execute statements depending on the result of the condition. There are 6 kinds of conditional statements: (1) If Statement, (2) If-Else Statement, (3) Nested-If Statement, (4) If-Else-If Ladder, (5) Switch statement, and (6) Nested Switch Statement.

The general form:
if ( expression)
statement;

Expression is relational or Boolean expression that evaluates to a TRUE (1) or FALSE (0) value. Statement may either be a single C Statement or a block of C statements. In an if statement, if the expression evaluates to (1), the statement that forms the target of the if statement will be executed. Otherwise, the program will ignore the statement.

If an if-else statement, if the expression is (1), the statement after the if statement will be executed. Only the code associated with the if or the code is associated with the else executes, never both. In C, the else is linked to the closest preceding if that does not already have an else statement associated with it. The general form of the if-else statement with block of statement is:
If (expression)
{
statement_sequence;
}
else
{
statement_sequence;
}

A common programming construct in C is the if-else- if ladder. In an if-else-if ladder statement, the expression are evaluated from the top downward. As soon as a true condition is found, the statement associated with it is executed and the rest of the ladder will not be executed. If none of the condition is true, the final else is executed. The final else is optional, you may include this part if needed in the program or you may not include if not needed.

The switch statement is a multiple-branch decision statement. In a switch statement, a variable is successively tested against a list or integer or character constants. If a match is found, a statement or block of statement is executed. The default part of the switch is executed if no matches are found. The break statement is used to terminate the statement associated with each case constant. It is a C keyword which means that at that point of execution, you should jump to the end of the switch statement by the symbol }.

The general form of the nested switch statement is:
switch (variable)
{
case constant:{
switch (variable)
{
case constant1:
statement sequence_1;
break;
case constant2:
statement_sequence_2;
break;
}
break;
}
case constant2:
statement sequence;
break;
default:
statement sequence;
}

Thursday, November 20, 2008

3rd- Learnings of the Week 1 [Caligdong]

INPUT STATEMENT is used to input a single character or a sequence of characters from the keyboard. Types of input statement:

Getch = A function used to input a single character from the keyboard without echoing the character on the monitor. Syntax: getch();
Example: ch = getch();

Getche = A function used to input a single character from the keyboard, the character pressed echoed on the monitor, line the READLN in PASCAL Syntax: getche();
Example: ch = getche();

Getchar = A function used to input a single character from the keyboard, the character pressed echoed on the monitor terminated by pressing Enter key. Syntax: getchar();
Example: ch = getchar();
Gets = A function used to input a single character from the keyboard, spaces are accepted, terminated by pressing enter key. Syntax: gets();
Example: gets(ch);

Scanf = A function used to input a single character or sequence of characters from the keyboard, it needs the control string codes in able to recognized. Spaces are not accepted upon inputting. Terminated by pressing spacebar. Syntax: gets();
Example: gets(ch);

OUTPUT STATEMENT is used to display the argument list or string on the monitor. Types of output statement:


Puts = A function used to display the argument list or string on the monitor. It does not need the help of the control string codes. Syntax: puts();
Example: puts(“hello”);

All format specifiers start with a percent sign (%) and are followed by a single letter indicating the type of data and how data are to be formatted.
%c – used for single char in C
scanf(“%c”, &ch); printf(“%c”, ch);

%d – decimal number (whole number)
scanf(“%d”,&num); printf(“%d”,num);

%e – scientific notation / exponential form
scanf(“%e”, &result); printf(“%e”, result);

%f – number with floating or decimal point
scanf(“%f”,&pesos); printf(“%f”,pesos);

%o – octal number
scanf(“%o”, &valuet); printf(“%o”, value);

%s– string of characters
scanf(“%s”,&str); printf(“%s”,str);

%u – unsigned number
scanf(“%u”, &value); printf(“%u”, value);

%x– hexadecimal numbers
scanf(“%x”,&value); printf(“%x”,value);

%X – capital number for hexadecimal number
scanf(“%X”, &nos); printf(“%X”, nos);

%%– print a percent sign
scanf(“%%”,&value); printf(“%%”,value);

List of commonly used escape sequence:
\\ - prints backslash
\’ – prints single quotes
\” – prints double quotes
\? – prints question mark
\n - newline

A function gotoxy is used to send the cursor to the specified location. Syntax: gotoxy(x,y);
Example: gotoxy(5,10);

/*y is assigned a numeric literal*/

It stores a value or a computational result in a variable. They are commonly used to perform most arithmetic operations in a program. It can also be used in printf() statement. Syntax: variable = expression
Example: y=1;

Saturday, October 11, 2008

Learnings of the Week (Quennie Rose Colegado)

Conditional Statements
Are statements that check an expression then may or may not execute a statement or group of statement depending on the result of the condition.
Types of Conditional Statements:
The If Statement
The If-Else Statement
The Nested-If Statement
The If-Else-If Ladder
The Switch Statement
The Nested Switch Statement
The If Statement - In an if statement, if the expression evaluates to TRUE (1), the statement or the block of statements that forms the target of the if statement will be executed. Otherwise, the program will ignore the statement or the block of statements.
The If-Else Statement - If an if-else statement, if the expression is TRUE (1), the statement or block of statement after the if statement will be executed; otherwise, the statement or block of statement in the else statement will be executed.
Note: Only the code associated with the if or the code that is associated with the else executes, never both.
The Nested-If Statement - One of the most confusing aspects of the if statement in any programming language is nested ifs. A nested if is an if statement that is the object of either an if or else. This is sometimes referred to as “an if within an if.” The reason that nested ifs are so confusing is that it can be difficult to know what else associates with what if.
The Else-If-Else Ladder - In an if-else-if ladder statement, the expression are evaluated from the top downward. As soon as a true condition is found, the statement associated with it is executed and the rest of the ladder will not be executed. If none of the condition is true, the final else is executed.
The Switch Statement - In a switch statement, a variable is successively tested against a list or integer or character constants. If a match is found, a statement or block of statement is executed. The default part of the switch is executed if no matches are found.
The Nested Switch Statement - It is just a switch within a switch statement.
Conditional Statements
Are statements that check an expression then may or may not execute a statement or group of statement depending on the result of the condition.
Types of Conditional Statements:
The If Statement
The If-Else Statement
The Nested-If Statement
The If-Else-If Ladder
The Switch Statement
The Nested Switch Statement
The If Statement - In an if statement, if the expression evaluates to TRUE (1), the statement or the block of statements that forms the target of the if statement will be executed. Otherwise, the program will ignore the statement or the block of statements.
The If-Else Statement - If an if-else statement, if the expression is TRUE (1), the statement or block of statement after the if statement will be executed; otherwise, the statement or block of statement in the else statement will be executed.
Note: Only the code associated with the if or the code that is associated with the else executes, never both.
The Nested-If Statement - One of the most confusing aspects of the if statement in any programming language is nested ifs. A nested if is an if statement that is the object of either an if or else. This is sometimes referred to as “an if within an if.” The reason that nested ifs are so confusing is that it can be difficult to know what else associates with what if.
The Else-If-Else Ladder - In an if-else-if ladder statement, the expression are evaluated from the top downward. As soon as a true condition is found, the statement associated with it is executed and the rest of the ladder will not be executed. If none of the condition is true, the final else is executed.
The Switch Statement - In a switch statement, a variable is successively tested against a list or integer or character constants. If a match is found, a statement or block of statement is executed. The default part of the switch is executed if no matches are found.
The Nested Switch Statement - It is just a switch within a switch statement.
Conditional Statements
Are statements that check an expression then may or may not execute a statement or group of statement depending on the result of the condition.
Types of Conditional Statements:
The If Statement
The If-Else Statement
The Nested-If Statement
The If-Else-If Ladder
The Switch Statement
The Nested Switch Statement
The If Statement - In an if statement, if the expression evaluates to TRUE (1), the statement or the block of statements that forms the target of the if statement will be executed. Otherwise, the program will ignore the statement or the block of statements.
The If-Else Statement - If an if-else statement, if the expression is TRUE (1), the statement or block of statement after the if statement will be executed; otherwise, the statement or block of statement in the else statement will be executed.
Note: Only the code associated with the if or the code that is associated with the else executes, never both.
The Nested-If Statement - One of the most confusing aspects of the if statement in any programming language is nested ifs. A nested if is an if statement that is the object of either an if or else. This is sometimes referred to as “an if within an if.” The reason that nested ifs are so confusing is that it can be difficult to know what else associates with what if.
The Else-If-Else Ladder - In an if-else-if ladder statement, the expression are evaluated from the top downward. As soon as a true condition is found, the statement associated with it is executed and the rest of the ladder will not be executed. If none of the condition is true, the final else is executed.
The Switch Statement - In a switch statement, a variable is successively tested against a list or integer or character constants. If a match is found, a statement or block of statement is executed. The default part of the switch is executed if no matches are found.
The Nested Switch Statement - It is just a switch within a switch statement.

Saturday, September 20, 2008

Learnings of the Week

Conditional Statements
Are statements that check an expression then may or may not execute a statement or group of statement depending on the result of the condition.


Types of Conditional Statements:
The If Statement
The If-Else Statement
The Nested-If Statement
The If-Else-If Ladder
The Switch Statement
The Nested Switch Statement


The If Statement -
In an if statement, if the expression evaluates to TRUE (1), the statement or the block of statements that forms the target of the if statement will be executed. Otherwise, the program will ignore the statement or the block of statements.

The If-Else Statement - If an if-else statement, if the expression is TRUE (1), the statement or block of statement after the if statement will be executed; otherwise, the statement or block of statement in the else statement will be executed.
Note: Only the code associated with the if or the code that is associated with the else executes, never both.

The Nested-If Statement - One of the most confusing aspects of the if statement in any programming language is nested ifs. A nested if is an if statement that is the object of either an if or else. This is sometimes referred to as “an if within an if.” The reason that nested ifs are so confusing is that it can be difficult to know what else associates with what if.

The Else-If-Else Ladder -
In an if-else-if ladder statement, the expression are evaluated from the top downward. As soon as a true condition is found, the statement associated with it is executed and the rest of the ladder will not be executed. If none of the condition is true, the final else is executed.

The Switch Statement - In a switch statement, a variable is successively tested against a list or integer or character constants. If a match is found, a statement or block of statement is executed. The default part of the switch is executed if no matches are found.

The Nested Switch Statement -
It is just a switch within a switch statement.

[Emerald May L. Caligdong]

Tuesday, September 16, 2008

LEARNINGS OF THE WEEK (Laraflyn B. Camay)

Our lesson last week, Sept. 8-12, 2008 is all about the C programing language.

The c program is composed of 3 functions: the main function, the function greet1 and the function greet2.

So, we can make a program that is made up of other function aside from the main function.

The main( ) function should always be present in every C program.

Functions are the building blocks of C in which all program activity occurs. It is also called a subprogram or subroutine. It is a part of a C program that performs a task, operation or computation then may return to the calling part of the program. Other functions aside from the main( ) can only be executed by the program through a “function call”.

Function call is a C statement that is used to call a function to execute C statements found inside the function body.

Going back to the example, greet1( ); is an example of a function call, calling the function greet ( ). main ------clrscr------printf greet1( ) function call------greet1( ) functiongreet2 function call----greet2( ) function getch( )

FILE TYPES are
a. alloc.h – declares memory management functions.
b. conio.h – declares various functions used in calling IBM-PC ROM BIOS.
c.ctype.h – contains information used by the calssification and character convertion macros.
d.math.h – declares prototype for the math functions.
e. stdio.h – defines types and macros needed for standard I/O.
f. string.h – declares several string manipulation and memory manipulation routines.

A Symbol is a line char used to move the cursor to the next line

‘ ‘ – single quote is used for single character / letter.
“ “ – double quote is used for two or more character
{ - open curly brace signifies begin
} – close curly brace signifies end
& - address of operator
* - indirection operator / pointer

STRUCTURE:
#include directive – contains information needed by the program to ensure the correct operation of C’s Standard library functions.
#define directive – used to shorten the keywords in the program.
Variable declaration section – it is the place where you declare your variables.
Body of the program – start by typing main() and the { and }. All statements should be written inside the braces.

LEARNINGS OF THE WEEK (Laraflyn B. Camay)

nIdentifiers are composed of a sequence of letters. Digits, and the special character _ (underscore). You must also avoid using names that are too short or too long and limit the identifiers from 8 to 15 characters only.

Variables are identifiers that can store a changeable value. These can be different data types.

It must consist only of letters, digits, and underscore and must not begin with a digit.
An identifier defined in the C standard library should not be redefined.
It is case sensitive; meaning uppercase is not equal to the lowercase.
You must not also include embedded blanks.

You must not also use any of the C language keywords as your variable/ identifier and do not call your variable / identifier by the same name as other functions.

All variables must be declared before they may be used.

Before declaring variables, specify first the data type of the variable/s. Variables must be separated by comma. All declarations must be terminated by a semicolon (;).
There are two kinds of variables. The LOCAL VARIABLE,
variables that are declared inside a function. It can only be referenced by statements that are inside the block in which the variables are declared and GLOBAL VARIABLES.
Constants are identifier / variables that can store a value that cannot be changed during program execution. Example is the const int count = 100;
where integer count has a fixed value of 100.

Operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. There are three classes of operators in C: arithmetic, logical and relational, and bitwise.
The arithmetic operators are + for addition, - for subtraction, * for multiplicsation, / for divsion, % for modulus divisor, -- to decrement a value, and ++ to increment a value.

In the term relational operator, the word relational refers to the relationship values can have with one another. In the term logical operator, the word logical refers to the ways these relationships can be connected together using the rules of formal logic.
hh!
hehe.
The relational operators are > for greater than, >= for greater than or equal to, <>
The logical operators are && (action is 'and'), (action is 'or') and ! (action is 'not').
Bitwise operators are the testing, setting or shifting of the actual bits in a byte or a word, which corresponds to C’s standard char and int data types and variants. They cannot by used on type float, double, long double, void or other more complex types.

? Operator is a very powerful and convenient operator that can be used to replace certain statements of the if-then-else form.
Expression refers to anything that evaluates to a numeric value.

The Order of Precedence is:
()
!, unary +, -
*. /. %
binary + , -
<, <=, >, >=
==, !=
&&