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.
Kamis, 18 Desember 2008
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.
// 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>_
//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
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
-------------------
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
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.
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.
Langganan:
Postingan (Atom)