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>_
Sabtu, 08 November 2008
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.
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.
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
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
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.
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.
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 ^_^
by Chrifto M. Sepang ^_^
Langganan:
Postingan (Atom)