Thursday, September 25, 2008

PROGRAMMING (*M.N. Sison*)

PROGRAMMING
n \n – is a line char used to move the cursor to the next linen
‘ ‘ – single quote is used for single character / letter.n
“ “ – double quote is used for two or more charactern
{ - open curly brace signifies beginn } – close curly brace signifies endn & - address of operatorn * - indirection operator / pointer


Structure of a simple C program
#include
#define directive
main()
{variable declaration section;
____________________________________________}
Commonly used include files in C language
.n alloc.h – declares memory management functions
.n conio.h – declares various functions used in calling IBM-PC ROM BIOS
.n ctype.h – contains information used by the calssification and character convertion macros.n math.h – declares prototype for the math functions
.n stdio.h – defines types and macros needed for standard I/O
.n string.h – declares several string manipulation and memory manipulation routines.
Types of Conditional Statement
The If Statement
The If-Else Statement
The Nested-If Statement
The If-Else-If Ladder
The Switch Statement
The Nested Switch Statement
The general form of the If statement is:
if ( expression)
statement;
The general form of the If statement with block statement is:
if ( expression)
{
statement_sequence;
}
The general form of the if-else statement is:
If (expression)
statement_1;
else
statement_2;
The general form of the if-else statement with block of statement is:
If (expression)
{
statement_sequence;
}
else
{
statement_sequence;
}
The general form of the if-else-if ladder statement is:
if ( expression_1)
statement_1;
else if (expression_2)
statement_2;
else if (expression_3;
statement_3;
:
:
else
statement_else;
The general form of the switch statement is:
switch (variable)
{
case constant1:
statement sequence_1;
break;case constant2:
statement_sequence_2;
break;
:
:
default:
statement_sequence_default;
}
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;
}

No comments: