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

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.

Sunday, August 31, 2008

LEARNINGS OF THE WEEK - by CALIGDONG

we have discussed about the history of the C language. and also about flowcharting and algorithms.

I have learned that the B language that Ken Thompson developed is a successor of Basic Command Programming Language (BCPL) which was developed by Martin Richards. To augment B's power, Dennis Ritchie invented and first implemented the C Programming Language in Bell Laboratory. It was originally developed under UNIX environment running in DEC PDP-11.

C stands for Combined Programming Language and is also called System Programming Language(SPL) It did not become immediately popular after its creation. It took almost 6 years when many people read and learned the usefulness of the language after Brian Kernighan and Dennis Ritchie published the book "THE C PROGRAMMING LANGUAGE".

By year 1983, the American National Standard Institute (ANSI) created the X3J11 committee to provide the machine definition of the language and was then approved in 1989. ANSI cooperated with the International Standard Organization (ISO) to refer to as ANSI/ISO 9899:1990".

C language is considered as a middle-level language which means that it combines elements of high-level language with the functionalism of assembly language. It allows manipulation of bits, bytes, addresses the basic elements with which the computer functions.

C is sensitive to input commands, output commands and special words. That's why they are referred to as reserved words allow the use of lower case only It has only 32 keywords (27 from Kernighan and Ritchie and 5 from the ANSI Standardization Committee).


It was initially used for system development work, in particular the programs that make up the OS. It produces codes that run as fast as codes written in assembly language.

C is used in the following: Operating System, Language compilers,Assemblers, Text Editors, Print Spoolers, network devices, modern programs, databases, language interpreters and in utilities.

There five features of C language. First, it is a simple core language. Second, it focus on procedural programming paradigm. Third, parameters are always passed by value not by reference. Fourth, it encourages the creation of libraries user-defined functions. And last, it is flexible when it allows unrestricted conversion of data from one type to another.

FLOWCHARTING is the use of symbols and phrases to designate the logic of how a problem is solved. it is the common method for defining the logical steps of flow within a program by using a series of symbols to identify the basic input, process and output function within a program. it is a two-dimensional representation of an algorithm; the predefined graphic symbols of a flowchart are used to indicates the various operations and the flow of control .
A diagram representing the logical sequence in which a combination of steps is to be performed. It is a blueprint of the program.

ALGORITHM is a finite set of instructions that specify a sequence of operations to be carried out in order to solve a specific problem or class of problems.

SYMBOLS USED IN FLOWCHARTING

Terminal - is used to signify the beginning and end of flowchart.

Preparation/Initialization - signifies the preparation of data and used to select initial conditions. it also used to represent instructions or groups of instructions that will alter or modify a program's course of execution.

Input/ Output - shows input and output. Data are to be read into the computer memory from an input device or data are to be passed from the memory to an output device.

Processing -performs any calculations that are to be done.

Decision -signifies any decisions that are to be done

On-page Connector-shows the entry or exit point of the flowchart.A non-processing symbol used to connect one part of a flowchart to another without drawing flow lines. Conserves space by keeping related blocks near one another, reduces the number of flow lines in complex programs, and eliminates cross lines from taking place

Off-page Connector-Designates entry to or exit from one page when a flowchart requires more than one page


Flowlines- Signifies the process that is to be executed next.



CONTROLS

  • Sequence
  • Selection (if-then-else)
  • Repetition (Looping)

Saturday, August 30, 2008

Learnings of the Week (aug 25-29)

During this week, we have tackled about the C language, its history, uses, features, and also about flowcharting.

Without the idea of Dennis Ritchie, C language would have not been discovered especially its relevance and importance to us. C was invented and first implemented by Dennis Ritchie to augment B's power, which was the first computer language before C.

C did not become immediately popular after its creation and took almost six years when many people read and learned the usefulness of the language after Brian Kernighan and Dennis Ritchie created a famous book called "The Programming Language."

C was initially used for system development work, in particular the programs that make up the operating system. C is used mainly because it produces codes that run as fast as codes in assembly language.

Some examples of C are the operating system, the language compilers, assemblers, the text editors, the network devices, etc.

The features of C are: it is a simple core language, such as math functions and file handling; it focuses on a procedural programming paradigm which facilitates for programming in a structured style and others.



¡
¡

Friday, August 29, 2008

Learnings of the Week (Quennie Rose Colegado)

This weak, we discussed about the Flowcharting and algorithms
Flowcharting is defined as
A common method for defining the logical steps of flow within a program by using a series of symbols to identify the basic input, process and output function within a program.
A two-dimensional representation of an algorithm; the predefined graphic symbols of a flowchart are used to indicates the various operations and the flow of control .

Algorithm is a finite set of instructions that specify a sequence of operations to be carried out in
order to solve a specific problem or class of problems.

Basic Symbols Used in Flowcharting
Terminal

Used to signify the beginning and end of flowchart.

Preparation/Initialization

Signifies the preparation of data.

Used to select initial conditions.

Used to represent instructions or groups of instructions that will alter or modify a program’s course of execution.


Input/Output
Shows input and output. Data are to be read into the computer memory from an input device or data are to be passed from the memory to an output device.

Processing

Performs any calculations that are to be done.

Decision

Signifies any decisions that are to be done

On-page Connector

Shows the entry or exit point of the flowchart.

A non-processing symbol used to connect one part of a flowchart to another without drawing flow lines.

Conserves space by keeping related blocks near one another, reduces the number of flow lines in complex programs, and eliminates cross lines from taking place.

Off-page Connector

Designates entry to or exit from one page when a flowchart requires more than one page.

Flowlines

Signifies the process that is to be executed next.

Basic Control Structures

Sequence

Selection (if-then-else)

Repetition (Looping)

Sequence

A process executed from one to another in a straightforward manner.

Repetition (Looping)

This structure provides for the repetitive execution of an operation or routine while the condition is true. The condition is evaluated before executing any process statement. As long as the condition is true, the process is executed, otherwise, control flows out of the structure.

Example of Repetition (Looping)

Construct a flowchart that will count from 1 to 10 and print each number counted using the do-while-repetition structure .Write its equivalent algorithm.

Commonly Used Operators in Flowcharting

Arithmetic Operators

+ addition

- Subtraction

* Multiplication

/ Division


Relational Operators

= equal

> Greater than

<>

<> Not equal

> Greater than or equal to

< less than or equal to

Logical operators

&& AND

|| OR

! NOT

Sunday, August 17, 2008


ASCII
stands for American Standard Code for Information Interchange.


Computers can only understand numbers...
so, an ASCII code is the numerical representation of a character such as 'a' or '@' or an action of some sort.

ASCII was developed a long time ago and now the non-printing characters are rarely used for their original purpose.
Below is the ASCII character table and this includes descriptions of the first 32 non-printing characters.
ASCII was actually designed for use with teletypes and so the descriptions are somewhat obscure.
If someone says they want your CV however in ASCII format, all this means is they want 'plain' text with no formatting such as tabs, bold or underscoring - the raw format that any computer can understand.
This is usually so they can easily import the file into their own applications without issues.
Notepad.exe creates ASCII text, or in MS Word you can save a file as 'text only'.


Bits Reading
Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Hexadecimal
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F

Definition:
Bits - the smallest unit of data in a computer. It is an acronym for binary digits.
Bytes - it contains 8 bits.
Hexadecimal format - the numbering system that involves the digits "0 though F".

Converting binary digits into decimal format:
Example:
01000001 to be converted into decimal number.
0
1
0
0
0
0
0
1
128
64
32
16
8
4
2
1


if the you total 1 + 64, it is equal to decimal 65.

Converting decimal to Hexadecimal format:
For example: decimal 65 to be converted hexadecimal format:
65 divided by 16
it is equal to the quotient 4 with remainder 1
so the hexadecimal format is equal to 41h.

Sunday, August 10, 2008

Learnings of the week


This week, we have discussed about the three fundamentals of the computer system and the four different types of software.

The three fundamentals of the computer system are the system unit, the output devices and the input devices.


The four different types of software are the software, the data, the programs, and the fundamental idea.

Software provides the commands that tell the hardware what task to perform, what to read and write, how to send the end result (output) to a monitor or printer. It is also the programs or data that a computer uses. Also kept on some hardware device such as a hard disk or floppy disk and consists of both programs and data. Programs are list of instructions for the processor. Data can be any information that a program needs like character data, numerical data, image data, audio data, and countless other types. Fundamental Idea, where both programs and data are saved in computer memory in the same way. The electronics of computer memory (both main memory and secondary memory) make no distinction between programs and data.

There are also different kinds of software which are the application software, the operating system and the programming languages.

Application software
are programs that people use to get their work done. It may include data entry, update query and report programs, productivity software for spreadsheets, word processing, databases and custom accounting programs for payroll, billing and inventory. It is designed to help people with specific task such as making a spreadsheet of creating a graphic image. Operating System is software which controls the computer and runs applications, it keep all the hardware and software running together smoothly. It communicates information from the application software to a computer’s program. Programming Languages are used to create all other software whether it is Operating system or Application software.

There are different kinds of languages such as the
Machine-LanguageAssembly, LanguageFORTRAN (Formula Translation), ALGOL (ALGOrithmic Language), COBOL (Common Business Oriented Language), BASIC (Beginner’s All-purpose Symbolic Instruction Code), Program Languages, PASCAL, LOGO, C languages (C and C++)LISP and PROLOG (PROgramming for LOGic), ADA, Java, and the Fourth and Fifth Generation Languages.
This week is a very tough and tiring one because of series of quizzes in tle but in spite of the difficulty, I have learned a lot about computers more on their different functions.