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 + , -
<, <=, >, >=
==, !=
&&

Friday, September 12, 2008

Learnings of the Week (Quennie Rose Colegado)

The C programing language. 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 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( ) functiongreet2 function call----greet2( ) function getch( )

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

SYMBOLS:
\n – 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

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 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( ) functiongreet2 function call----greet2( ) function getch( )

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

SYMBOLS:
\n – 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.


SAMPLES:
Example1:

#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 Output1:

10 5
15 10
10 5

Example2:
#include
main()
{
clrscr( );
printf (“Hi”);
greet1( );
greet2( );
getch( );
}
greet1 ( )
{
printf ( “Hello”);
}

greet2 ( )
{
printf (“How are you”);
}

Sample Output2:

Hi! Hello! How are you?


em. :))

[emerald may l. caligdong]


The C or the Combined Programming Language.

It uses some of the data types are the char, int, void, the floating, the double floating and some more.

char - values are used to hold ASCII characters or any 8-bit quantity.
int - values are used to hold real numbers. Real numbers have both an integer.

void – it has three uses.namely; (1)To declare explicitly a function as returning no value, (2) To declare explicitly a function as having no parameters, and (3) To create generic pointers.
float and double - values are used to hold real numbers. Real numbers have both an integer and fractional component.

These data types have its limitations. The following states the limit of each data type:

CHAR = from 0 to 255.

INT = -32768 to 32767.

VOID =not applicable for it is valueless.

FLOAT = 3.4 X 10-38 to 3.4 X 1038

DOUBLE FLOAT =1.7 x 10-308 to 1.7 x 10308.

The C Programming Language has 32 keywords. Twenty- seven which are given by Brian Kernighan and Dennis Ritchie standard and the five added by the ANSI (American National Standard Institute). Keywords in C are reserved words that have a special meaning. Reserved words are words “reserved” by the programming language for expressing various statements and constructs, thus, these may not be redefined by the programmer.

The following are the known 32 keywords:

auto break case char const continue def default do double else enum extern float for goto int long of register return short signed size struct switch type union unsigned void volatile if static while

em. :))

[emerald may l. caligdong]

Friday, September 5, 2008

Learnings of the Week (sept 1-4)

Last week, we have started our discussion on the C language. But this week, our lessons focuses on the data types used in programming the C or the Combined Programming Language.
Some of the data types are the char, int, void, the floating, the double floating and some more.
char - values are used to hold ASCII characters or any 8-bit quantity.

int - values are used to hold real numbers. Real numbers have both an integer.
void - The type void has three uses:
*To declare explicitly a function as returning no value.
*To declare explicitly a function as having no parameters.
*To create generic pointers.

float and double
- values are used to hold real numbers. Real numbers have both an integer and fractional component.
The range of char is from 0 to 255.
The range of int is -32768 to 32767.
The range of void is not applicable for it is valueless.
The range of float is 3.4 X 10-38 to 3.4 X 1038 while the range of double is 1.7 x 10-308 to 1.7 x 10308.
C has 32 keywords. Twenty- seven which are given by Brian Kernighan and Dennis Ritchie standard and the five added by the ANSI (American National Standard Institute). Keywords in C are reserved words that have a special meaning. Reserved words are words “reserved” by the programming language for expressing various statements and constructs, thus, these may not be redefined by the programmer.
The following are the known 32 keywords:
auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while

Next Week, we will continue discussing more about the C language.