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.
Kamis, 06 November 2008
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)