RSS2.0

Looking Something??



[WISE WORD] A Story About Frog

Friday, February 22, 2008

A Story About FROG

One day there was a competition. That was a race competition and the participants were frogs. The first frog who can climb and reach the top of the tower would be the winner. Then the competition was begun. Frogs were trying hard to climb that tower, many audiences screamed "It's impossible to reach the top of the tower because it's too high". What have the audiences said became true, many frogs were falling down. Finally just one frog left, and that frog can reach the top. He was a winner. He was succeeded lose his frightened. The audiences were confused why it could be happened. In fact the frog who was the winner was deaf so he couldn't hear what the audiences have screamed.


WHAT YOU THINK IT'S BECOME TRUE SO ALWAYS POSITIVE THINKING and WHAT YOU HEAR IS INFLUENTED YOUR MIND N POWER SO BECOME A "DEAF" IS THE BEST WAY, NEVER HEAR WORDS THAT IS NEGATIVE. BECAUSE THE NEGATIVE WORD CAN DROP OUR WISHED N OUR EFFORT...ALWAYS BELIEVES YOURSELF N NEVER SAY NEVER N IMPOSSIBLE!

[ Read More ]


[C Programming Language] Repetition/Looping in C Programming Language

Saturday, February 16, 2008

REPETITION / LOOPING IN C PROGRAMMING LANGUAGE

Repetiton / Looping :

- A process which is done contionusly until particular value. If the limit isn’t typed, then syntax will be error because that process will be an infinite loop.

Looping which is usually used is Counting Loops. Why is it called conting loops? Because its repetition is managed by a loop control variable whose value represents a count. It is used when we can determine how many loops will be needed exactly.

The pseudocode of Counting Loops :

Set loop control variable to an initial value of 0

While loop control variable <>

... //Do something multiple times

Increase loop control variable by 1.

Three types of Counting Loops in C Programming Language :

a. FOR

Syntax :

for(initialize; test; update)

{

//Steps to perform each iteration

}

Initialize - - > initial condition of control variable

Test - - > relational expression which is a condition

Update - - > change the value of control variable

For Example :

int p = 0;

int i;

for (i=0;i<10;i++)

{

p=p+i;

}

Note :

p = p + 1 is equal with p++ and p += 1.

Flowchart :

b. WHILE (Pre Tested Loop) :

Syntax :

While(condition)

{

//Steps to perform. These should eventually

// result in condition being false

}

For Example :

int p=0;

int i=0; //initialization

while (i<10) //testing

{

p=p+i;

i++; //updating

}

Note :

If any of initialization, testing and updating are skipped, it may produce an infinite loop.

Flowchart :

c. DO-WHILE (Post Tested Loop) :

Syntax :

Do

{

//Steps to perform. These should eventually

// result in condition being false

}

While (condition);

For Example :

int i=0 //initialization

int p=0;

do

{

p=p+1;

i++; //updating

}

while (i<10); //testing

Flowchart :

Debug and Test Looping Programs :

1. Using debugger programs.

2. Use several printf statement to output the value of variables.

3. Testing the programs with try and error.

[ Read More ]


[C Programming Language] Standard Function in C Programming Language

C Programming Language Standard Function

Functions which is often used in C Programming Language :

a. printf

a function in stdio.h library which is used to show string and also placeholders to screen.

b. puts

a function used to show a string to screen when the placeholders isn’t used.

c. scanf

a function which is used to store data whose type is represented by a placeholder in string format to variable memory address which has been decided.

d. getch

a function which is used to read data whose type is character without key ENTER pressed and it won’t be showed. This function is usually used to show output on the screen until key ENTER pressed.

e. getche

a function which is used to read data whose type is character without key ENTER pressed and the character will be showed on the screen.

f. getchar

a function which is used to read data whose type is character, the character will be showed on screen and must be finished with key ENTER pressed.

g. clrscr

a function which is used to clear screen and move the cursor back to the upper left corner.

h. %3d dan %-3d

int x=1;

%3d will show : _ _ 1 - - > it still give 2 space

%-3d will show : 1 - - > empty space will be deleted.



Function Random and Randomize in Dev C++ :

1. Randomize :

To make randomize in order to produce a different random number every time the program running.

Syntax : srand ((unsigned)time(NULL));

2. Random(int num) :

To get a random number between 0 – (num – 1).

Syntax : int x = rand( )% (int num);

For example :

#include

#include

#include //definition of srand, rand

#include //definition of time

int main

{

int n,

x;

printf(“Enter the value of maximum random number : “);

scanf(“%d”,&n);

srand((unsigned)time(NULL));

x = rand()%100;

printf(“Random Number : %d\n”,x);

getch();

}

[ Read More ]


[C Programming Language] C Programming Language Main Structure

C Programming Language Main Structures

C Programming Language Elements :

1. Preprocessor directives

Command line which is given instruction to preprocessor.

There are two types of preprocessor : #include and #define.

#include library.h tell preprocessor the library to find the meaning of standard identifier.

#define NAME value tell preprocessor to change every identifier NAME with value before the program was compiled.

Example :

#include stdio.h

#define PI 3.14

2. Comment

Texts which is started with /* or // and finished with */, and contains information about program in order to make the program is understood easily by other programmer. Compiler will ignore comments.

3. Main Function

Syntax :

int main(void)

{

/* main function */

}

Main function is made up from 2 parts :

1. Declaration

2. Executeable Statement

4. Reserved Word and Identifier

Reserved Word :

- word which has special meaning in C and can’t be used again for other.

Example : int, void, double, return, etc.

Identifier :

a. Standard Identifier :

A word which has special meaning in C but it can’t be redefined by user(not recommended).

Example : printf, scanf, etc.

b. User Defined Identifier :

A word which is choosed by user to rename memory cell and user defined operation.

Example : miles, name, x, PI, etc


Expression Evaluation Rule :

1. Parentheses Rule

2. Operator Presedence Rule

From High to Low :

Function calls

!, +, -, & (operator unary)

*, /, %

+, -

<, <=, >=, >

==, !=

&&

||

=

3. Associative Rule

Unary - - > evaluate from Right to Left

Binary - - > evaluate from Left to Right



[ Read More ]


[C Programming Language] Branching (IF ELSE / SWITCH CASE) in C Programming Language

Friday, February 15, 2008

BRANCHING/ DECISION
(IF ELSE / SWITCH CASE)



Three Main Construction of Programming :

1. Sequential

2. Branching / Decision

3. Looping / Repetition

Branching :

- A process to make a decision based on the condition which has been evaluated before.

There are two types of branching :

1. IF – ELSE

Syntax : if (condition){

statement – 1;

statement – n;

}

else if (condition){

statement – 1;

statement – n;

}

Flowchart :

Example :

#include

#include

int main()

{

int T;

printf("Enter temperature (Celcius) : ");

scanf("%d",&T);

if (T>30)

{

printf("Arghhhhhhh, Hot!");

}

else if (T<0)

{

printf("Ouchhhhh, Cold !");

}

else printf("Yummy! Cool.");

getch();

return(0);

}

2. SWITCH – CASE

Syntax : switch (kondisi) {

case 1 : pernyataan-1;

break;

case 2 : pernyataan-2;

break;

.....

.....

case n : pernyataan-n;

break;

default : pernyataan-m

}

Flowchart :

Example :

#include

#include

int main()

{

char IP;

printf("Enter your result in alphabet : ");

scanf("%c",&IP);

switch (IP)

{

case 'A' : printf("4");

break;

case 'B' : printf("3");

break;

case 'C' : printf("2");

break;

case 'D' : printf("1");

break;

case 'E' : printf("0");

break;

default : printf("The input isn’t valid.");

}

getch();

return(0);

}

The difference between IF-ELSE and SWITCH-CASE :

IF ELSE :

To make a decision between 2 choices. For example :

If the value is greater than 70 (seventy) then the student passes the exam.

Else, the student doesn’t pass the exam.

SWITCH CASE :

To make a decision which has more than 2 choices. For example :

A is converted to 4.

B is converted to 3.

C is converted to 2.

D is converted to 1.

E is converted to 0.

[ Read More ]


[C Programming Language] C Simple Data Types

Thursday, February 14, 2008

Primitive Data Types


C has five primitive data types :

  1. int : used to define integer numbers

  2. char : contains ASCII Code character (128 characters)

  3. float : used to define floating point numbers

  4. double : used to define big floating point numbers

  5. bool : used to define two conditions --> true or false / 1 or 0


Example Variable Initialisation:

1. int
int tes;
tes = 5;

2. char
char answer = 'x';

3. float
float score = 85.3;

4. double
double height = 1,6782992;

5. bool
bool check = true;


Modifiers


The three data types above have the following modifiers.

  • short

  • long

  • signed

  • unsigned


The modifiers define the amount of storage allocated to the variable. ANSI has the following rules :
short int <= int <= long int
float <= double <= long double

































































































Implicit specifier(s)Explicit specifierBitsBytesMinimum valueMaximum value
signed charsame81−128+127
unsigned charsame810255
charone of the above81−128 or 0+127 or 255
shortsigned short int162−32,768+32,767
unsigned shortunsigned short int162065,535
intsigned int16 or 322 or 4−32,768 or
−2,147,483,648
+32,767 or
+2,147,483,647
unsignedunsigned int16 or 322 or 4065,535 or
4,294,967,295
longsigned long int324−2,147,483,648+2,147,483,647
unsigned longunsigned long int32404,294,967,295
long longsigned long long int648−9,223,372,036,854,775,808+9,223,372,036,854,775,807
unsigned long longunsigned long long int648018,446,744,073,709,551,615

Qualifier


1. Const

The const qualifier is used to tell C that the variable value can not change after initialisation.

For example, const float pi=3.14159;

So, the value of pi cannot be changed at a later time within the program.

Another way to define constants is with the #define preprocessor which has the advantage that it does not use any storage.

For example, #define PI 3.14159

2 . Volatile

volatile means the storage is likely to change at anytime and be changed but something outside the control of the user program. This means that if you reference the variable, the program should always check the physical address (ie a mapped input fifo), and not use it in a cashed way.

(www.space.unibe.ch)



[ Read More ]


[C Programming Language] Introduction to C Programming Language

Introduction


C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. It has since spread to many other platforms. Although predominantly used for system software, C is used not only for system but also for applications widely. C has also greatly influenced many other popular languages, especially C++, which was designed as an enhancement to C.

Philosophy


C is an imperative (procedural) systems implementation language. Its design goals were for it to be compiled using a relatively straightforward compiler, provide low-level access to memory, provide language constructs that map efficiently to machine instructions, and require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language.

Despite its low-level capabilities, the language was designed to encourage machine-independent programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with minimal change to its source code. The language has become available on a very wide range of platforms, from embedded microcontrollers to supercomputers.

Characteristics


As most imperative languages in the ALGOL tradition, C has facilities for structured programming and allows lexical variable scope and recursion, while a static type system prevents many unintended operations. Parameters of C functions are always passed by value. Pass-by-reference is achieved in C by explicitly passing pointer values. Heterogeneous aggregate data types (the struct in C) allow related data elements to be combined and manipulated as a unit. C has around 30 reserved keywords and the source text is free-format, using semicolon as a statement terminator (not a delimiter).

C also exhibits the following more specific characteristics:

  • Non-nestable function definitions, although variables may be hidden in blocks to any level of depth

  • Partially weak typing, for instance, characters can be used as integers in a way similar to assembly

  • Low-level access to computer memory via machine addresses and typed pointers

  • Function pointers allowing for a rudimentary form of closures and runtime polymorphism

  • Array indexing as a secondary notion, defined in terms of pointer arithmetic

  • A standardized C preprocessor for macro definition, source code file inclusion, conditional compilation, etc.

  • Complex functionality such as I/O and mathematical functions consistently delegated to library routines

  • Syntax divergent from ALGOL, often following the lead of C's predecessor B, for example using

    • { ... } rather than ALGOL's begin ... end

    • the equal-sign for assignment (copying), much like Fortran

    • two consecutive equal-signs to test for equality (compare to .EQ. in Fortran or the equal-sign in BASIC)

    • && and || in place of ALGOL's and and or, which

      • are syntactically distinct from the bit-wise operators & and | (B used & and | in both meanings)

      • never evaluate the right operand if the result can be determined from the left alone (short-circuit evaluation)



    • a large number of compound operators, such as +=, ++, etc.




Uses


C's primary use is for "system programming", including implementing operating systems and embedded system applications, due to a combination of desirable characteristics such as code portability and efficiency, ability to access specific hardware addresses, ability to "pun" types to match externally imposed data access requirements, and low runtime demand on system resources.

C has also been widely used to implement end-user applications, although as applications became larger much of that development shifted to other, higher-level languages.

One consequence of C's wide acceptance and efficiency is that the compilers, libraries, and interpreters of other higher-level languages are often implemented in C.

C is used as an intermediate language by some higher-level languages. This is implemented in one of two ways, as languages which:

  • Emit C source code, and one or more other representations: machine code, object code, and/or bytecodes. Examples: some dialects of Lisp (Lush, Gambit), Haskell (Glasgow Haskell Compiler); Squeak's C-subset Slang.

  • Emit C source code only, and no other representation. Examples: Eiffel, Sather; Esterel.


C source code is then input to a C compiler, which then outputs finished machine or object code. This is done to gain portability (C compilers exist for nearly all platforms) and to avoid having to develop machine-specific code generators.

Unfortunately, C was designed as a programming language, not as a compiler target language, and is thus less than ideal for use as an intermediate language. This has led to development of C-based intermediate languages such as C--.

Libraries


The C programming language uses libraries as its primary method of extension. In C, a library is a set of functions contained within a single "archive" file. Each library typically has a header file, which contains the prototypes of the functions contained within the library that may be used by a program, and declarations of special data types and macro symbols used with these functions. In order for a program to use a library, it must include the library's header file, and the library must be linked with the program, which in many cases requires compiler flags (e.g., -lm, shorthand for "math library").

The most common C library is the C standard library, which is specified by the ISO and ANSI C standards and comes with every C implementation. ("Freestanding" [embedded] C implementations may provide only a subset of the standard library.) This library supports stream input and output, memory allocation, mathematics, character strings, and time values.

Another common set of C library functions are those used by applications specifically targeted for Unix and Unix-like systems, especially functions which provide an interface to the kernel. These functions are detailed in various standards such as POSIX and the Single UNIX Specification.

Since many programs have been written in C, there are a wide variety of other libraries available. Libraries are often written in C because C compilers generate efficient object code; programmers then create interfaces to the library so that the routines can be used from higher-level languages like Java, Perl, and Python.

Related languages




C has directly or indirectly influenced many later languages such as Java, C#, Perl, PHP, JavaScript, and Unix's C Shell. The most pervasive influence has been syntactical: all of the languages mentioned combine the statement and (more or less recognizably) expression syntax of C with type systems, data models and/or large-scale program structures that differ from those of C, sometimes radically.

C Compiler


Dev-C++ GUI Screenshot


Dev-C++ is a free integrated development environment (IDE) distributed under the GNU General Public License for programming in C/C++. It is bundled with the open source MinGW compiler. The IDE is written in Delphi. The latest release of Dev-C++ version is 4.9.9.2 which is launched in February 22, 2005.


The project is hosted by SourceForge. Dev-C++ was originally developed by programmer Colin Laplace. Dev-C++ runs exclusively on Microsoft Windows.

The program itself has a look-and-feel similar to that of the more widely-used Microsoft Visual Studio. One additional aspect of Dev-C++ is its use of DevPaks, packaged extensions on the programming environment with additional libraries, templates, and utilities. DevPaks often contain, but are not limited to, GUI utilities, including popular toolkits such as GTK+, wxWidgets, and FLTK. Other DevPaks include libraries for more advanced function use.

Dev-C++ can be downloaded from : http://sourceforge.net/projects/dev-cpp/

Source : en.wikipedia.org/wiki
programmingtutorial.wordpress.com

[ Read More ]


[EVENT] Happy Valentines Day!!










[ Read More ]


About 7effrey

Sunday, February 10, 2008

7effrey

nothing special about me..
i'm just an ordinary man..
i look like in this picture..
wkwkwkw..
i will try to do my best in this blog..
i hope this blog can be useful for others..
so, please check this out everyday!!
Maybe, sometimes I give you a surprise..
Hahaha..

Hmm, I think my blog isn't perfect..
I hope you can give me any suggestion to make my blog better..
i'm very appreciate your comment..
At the end, thank you for visiting my blog..
I hope to seeing you again..

see ya!!


[ Read More ]