Kamis, 18 Desember 2008

Display "Hallo World" with Pascal Language

The very simple program of Pascal Programming. This program will display "Hallo World" and waiting input from user.

Program Lesson1_Program1; {Program caption}
Begin {no semicolon}
Write ('Hallo World');
Readln; {waitting from input user}
End.

After we run this program it will be give an output:

Hallo World

and waiting input from user.

Note : this syntax can be copy and paste to the notepad or

other text editor and save it with extention .pas (eg:

HalloWorld.pas)

Program
Folowing the title of the program.

Write()
Function to display the statemant ('Hallo World' in this case). If we want to display and the pointer go to the next line we can use Writeln().

Readln;
Waiting for user input.

{...}
A comment line. If we run the program it will be ignore it.

; (semicolon)
End every function which we are write before.

End.
Close the body of program when start with begin.


Other process of writting of this syntax:

Program Lesson1_Program2;begin
Write('Hallo World');Readln;End

This program also runs perfectly as the previous one. The only dfference is neatness and friendliness.

Display "Hallo World" with C# Language

This is the very simple program of C# language. It will display "Hallo World" and waiting input from user.

// Namespace Declaration

using System;

// Program start class
class Hallo_World
{
// Main begins program execution.
static void Main()
{
// Write to console
Console.WriteLine("Hallo World");

// Make window wait for input
Console.ReadLine();
}
}


After we run this program it will give an output:

Hallo World

And waiting input from user to terminate the program.



using system;
Indicates that we are referencing the System namespace. Namespaces contain groups of code that can be called upon upon by C# programs.
With the using System; declaration, you are telling your program that it can reference the code in the System namespace without pre-ending the word System to every reference.

class WelcomeCSS
The class declaration, contains the data and method definitions that your program uses to execute. Can use to decribe objects, such as structs, interfaces, delegates, and enum.
This particular class has no data, but it does have one method.

Main
The methed of class WelcomeCSS tells what this class will do when executed. It is the starting point of a program. Often called "entry point" If we recive the error message saying that it can't find the entry point, it means that we tried to compile an executable program without a Main method.

static
A static modifier preceeds the word Main, meaning that this method works in this spedific class only, rather than an insatne of class.
This is necessary, because when a program begins, no object instances exit.

void
Every mthod must have a return type. In this case it is void, means that Main doesnt return a value.

WriteLine(...)
Console is a class in the System namespace. WriteLine(...) is a methode in the Console class.
We use the ".", dot, operator to separate subordinate program elements.
Note that we could also write this statement

//
This is a single line comment mark, mean that they are valid until the end-of-line. For multiple lines use /*(statement)*/
Comment are ignore when we compile our program.

All statements end with a ";", semi-colon. Classes and methods begin with "{", left curly brace, and end with a "}", right curly brace. Any statements within and including "{" and "}" define a block. Blocks define scope (or lifetime and visibility) of program elements.

Console.ReadLine();
Waiting input from user.

Sabtu, 08 November 2008

Display "Hallo World" with Java Language

First you can write the program with the editor text like notepad. Save it with HalloWorld.java.

//File : HalloWorld.java
//Writer : Chrifto M Sepang
//Date : Nophember 8 2008
//Description : This program display "Hallo World" statement.

public class HalloWorld {
public static void main (String[] args) {
System.out.println("Hallo World");
}
}

After you write this code compille it with command (in command prompt):
javac HalloWorld.java

And than run it use command (in command prompt):
java HalloWorld

This command will be display:
C:\JavaPractice> java HalloWorld
Hallo World

C:\JavaPractice>_

Jumat, 07 November 2008

Make Function Call with Project at DevC++

First open DevC++, Click File, New, Project. At Project1 left click and make new file. Write your body program and safe it with extention .c (eg.: myTest.c).

tes.h is the library that we made by ourself.
In this main function we can call the function that we made it into next section.
testprint (); and bintang (); are the function call, it is separate by new line (\n, escape sequence).


Next, left click on Project1 again make new file and add your function description in this section. Save it in the extention .c (eg.: tes.c). You can add more than one function description in this section and call in to main function in myTest.c.


In this section there are two function description it is void testprint() it will display "Hallo World" with two new line. The second function it is void bintang() it will display the riferse of triangle that has 4 rows and 4 columns. Don't forget to include the general library of C Language it is stdio.h the abbreviaton of standart input output and .h the extention of header file library. You can add more function in this section.


The last section is make the header file of this project. Left click on Project1 and make new file write the syntax of header file and save it into .h extention (eg.: tes.h). In this section there are containt the function prototype.

The syntax #ifndef _tes_h it is to check if the header file library name tes.h exist on the main program if yes we define it use #define _tes_h and this library function will be end with #endif. If there aren't exist it cannot use this function.
void testprint (); and void bintang (); are the function prototype of their function call and function description on the section above.

The result of this project is




I hope you understand and dont forget to try it.

For more informataion contact me at: chrifto@yahoo.co.id or chrifto@gmail.com
Practice Make Perfect ^_^

by: Chrifto M Sepang
Fear the Lord is the Beginning of Knowledge

Kamis, 06 November 2008

Program Untuk Menampilkan Matakuliah

Deskripsi: Program ini akan meminta user untuk memasukan hari dan menampilkan matakuliah pada hari tersebut.
-------------------

Algoritma
Minta input user untuk menentukan hari senin, selasa, rabu, kamis atau jumat.
Pilih:
1. hari senin
2. hari selasa
3. hari rabu
4. hari kamis
5. hari jumat, simpan pada variabel hari
Jika hari = 1 atau hari = 3 atau hari = 5, Jika ya, tampilkan Jam Kelas dan Matakuliah pada hari tersebut. Jika tidak, check Jika hari = 2 atau hari =4, Jika ya, tampilkan Jam Kelas dan Matakuliah pada hari tersebut. Jika tidak tampilkan pesan error.

hints : Gunakan if else atau switch.


Tampilan :

Program Untuk Menampilkan Jam & Matakuliah
Hari Kuliah:
1. Senin
2. Selasa
3. Rabu
4. Kamis
5. Jumat

Masukan pilihan anda: 1

Hari Senin
Jam Matakuliah
07.00-08.00 Data Structure
08.00-09.00 System Analysis and Design
09.00-10.00 Computer Graphics
10.00-11.00 Operating Systems
15.00-16.00 Introduction to Database
16.00-17.00 Statistic and Probability

Karnaugh Map

Exemple

Function

Function adalah pecahan program yang lebih kecil.

Menggunakan function:
1. Understanable and manageable parts
2. Reused the codes (block code)
3. Standard function -> printf(); scanf(); getch();

Three main part function:
1. Prototype function
2. Function call
3. Function Definition

Prototype Function
Prototype function is the declaration of a function. It is declare into global declaration. There are two type of declaration its global declaration and local declarataion. The global declaration it is where the function declare, not only function variable or struct or objeck can be declare in this area. The area of global declaration it is on the main function of c language program and under the include of header file of this language.
The local declaration it is in the body or block of main function. We can declare variable and others in this area.

#include of the header file
//# said prototype declaration, the beginning of writting the c language program

Global Declaration;

int main () //main function
{
Local Declaration;

return 0;
}


Function Call
Function call is the calling of the function that call the proses of this function into main function or it can call from others function.

int main ()
{
...

function call;

...
return 0;
}


Function Definition
Function definition is the definition or description of the function body. It usualy after main function or before main function. If the function definition before main function it not be necessary to use prototype function.

int adding(int a, int b)
{
c = a+b;

return (c);
}


I hope you enjoy with this learning. Don't be borring and always try to write the program. Enjoy your life with programming. Programming Make Life Easy.

For more information contact me into chrifto@yahoo.co.id or chrifto@gmail.com

Practice Make Perfect ^_^

by : Chrifto M Sepang
Fear the Lord is the Beginning of Knowledge.

Constants

There are three constants in C Language it's Special Character Constants (escape sequences), String Constants, Symbolic Constants.

Special Character Constants (Escape Sequences)
\n - newline
\r - carriage return
\a - bell
\t - horizontal tab
\f - from feed
\v - vertical tab
\\ - backslash. As the character '\' is alreadyy used to indicate the start of escape sequences, a double slash is needed to print the slash character.
\" - quotion mark. As the quotion mark is already used to mmark the start and end of a string, \" - is needed to print the quotion ark itself.
\% - precentage sumbol. As % is already used in the format specifier, \% is needed to print the % character.

String Constants
"Hallo World"
printf ("Hallo World\n");
The string constants is always inside " " signed.

Symbolic Constants
#define
define symbols for constants of integer float, character or string type.

I hope you understand with these three constants, command me for more information.

Rabu, 05 November 2008

Three Steps to Make Program

1. Understand the problem
2. Develop the solution
3. Write the program

Repetation

In all programming language repetation include to write the program if the program need it. Repetation repeat the operation in the body or block of this repetation. Repetation usually called like looping.
If we know the number of looping or the end of the loop we can use for() loop, than if we dont know how the loop will be ended we use while() loop. If the execution is minimal one we use do while().

Looping using for

for (j=1, i = 5 ; i > 0 ; i--)
j = j*i;

This for loop means variable of j times with i and it's include into j variable. The output of this program is j is equal to 120.


Looping using while

while (condition is true)
{
execute the statement in this block
}
//
{ } it's a block.


Looping using dowhile
do
{
execut the statement in this block
} while (condition is true);
// ; dont forget to add semmicolon if we use c language.

These three are the basic of the repetition.


by: Chrifto M Sepang

for more information contact me at:
chrifto@gmail.com, or
chrifto@yahoo.co.id

Selection

Generally all programming language has selection in to writting the program. Selection means in the program we select it into two posibility or more. In selection we use statement if and else.

Example:
if (age >= 17)
display "adult"
else
display "child"

In this case the program will be display "adult" if the age of people is greater than or equals to 17, and it will be display "child" if the age of people is less than 17.

The Basic Library of C Language

The basic Library in C Language is stdio.h, where std is standard, io is input output and .h is the extention of header library.

There are two basic function in these library it is printf() funtion and scanf() function.
- printf(); it is use to display the string, example to display "Hallo World" we can use this function it is: printf ("Hallo World"); //ended with semicolon
- scanf(); it is use to insert the data. The data stored use this function, example to store number 7 we can use this function it is: scanf("%d", &data_insert); //%d means the data we want to store have integers type, &data_insert means the data we stored it into a variable called data_insert.

Selasa, 04 November 2008

Bahasa Pemrograman Dasar

C language is the basic programming language. We can use turbo c, borland c, or dev c. This is the basic programming language for c++ programing, object oriented programming, java programing, c# programming, visual programming, graphic programming and other. So if you want to be a programmer I sugest you to practice programming with c programming language.

by Chrifto M. Sepang ^_^