Condotional is used for make what happen if the condition is
true and false. In daily activiton, we also use conditional. Example, if today
I don’t go to school, I help my father.
And in C programming also use conditional.
1.If (withoue "else")
Condition true: run by “if”.
Condition false: out of “if”.
Format:
if(.........){
2. If-else
Condition true: run by “if”.
Condition false: run by “else”.
Format:
if(..................){
}
else{
3.Conditional expresions
Same with number 2, but use different format.
Format:
exp1?exp2:exp3;
For example you can download here :
Example 3
For example you can download here :
Example 4
Example 3
4. Switch-case
There are some condition, sometimes use "default" if condition 1, 2, etc is not filled.
Format:
switch(exp){
case (exp_value) :
statement;
case (nilai_value) :
statement;
default :
statement;
}
For example you can download here :
Example 4
No comments:
Post a Comment