Hye Guys, This Is Usman and today we will be discussing about loops, conditions and format of switch structure.first of all let us see what a condition is.A condition is a statment which returns either true or false.if our given condition is right, it will return us true else it returns us false.for example if i have a int a = 5; and int b = 10; then i wrote this condition
_____
(a<b) because i am telling the truth so (a<b) returns me true.if i wrote the condition like this (a>b) it is clearly be seen that i am a lier how can 5 be greater then 10.so (a>b) returns me false.In programing we use these conditions to make dececions.for making decesions we use "if", "else if", and "else if else". see the example code http://www.facebook.com/note.php?created&¬e_id=122379541170699 and you will see why we use them and also you will find out the syntex of conditions.http://www.facebook.com/note.php?created&¬e_id=122385107836809
if else is if your condition returns true then do this , if not do that. do that is in else part .just like that if else if. it is a nested if see other examples of if else if you will be cleared about else if and if else if
Next is loop.In programing we use loops to execute a segment of code again and again.there are three kind of loops. do while loop, for loop and while loop.The method of writing For loop is this
for(int i = 0;i<5;i++){
Do this ;
}
we set our int i to 0 and after that there is a condition that returns us true of false or prity much compare our i against 5, because we want our code to execute 5 times .and the last thing is i++ which is incrementing i one by one.as long as our condition is returning us true, our code will be executeed and at the time when our condition i<5 returns us false (when i become 6) then our loop stops runnning.
see the example you will see how to use all the loops http://www.facebook.com/note.php?created&¬e_id=122384654503521
finally we are going through switch . when ever you have to cheack many conditinos say 100 conditions then instead of writing such nested conditions we use switch . see the example you will see why http://www.facebook.com/note.php?created&¬e_id=122387414503245 so see you soon guys. this is usman Signing off. Gud bye
_____
(a<b) because i am telling the truth so (a<b) returns me true.if i wrote the condition like this (a>b) it is clearly be seen that i am a lier how can 5 be greater then 10.so (a>b) returns me false.In programing we use these conditions to make dececions.for making decesions we use "if", "else if", and "else if else". see the example code http://www.facebook.com/note.php?created&¬e_id=122379541170699 and you will see why we use them and also you will find out the syntex of conditions.http://www.facebook.com/note.php?created&¬e_id=122385107836809
if else is if your condition returns true then do this , if not do that. do that is in else part .just like that if else if. it is a nested if see other examples of if else if you will be cleared about else if and if else if
Next is loop.In programing we use loops to execute a segment of code again and again.there are three kind of loops. do while loop, for loop and while loop.The method of writing For loop is this
for(int i = 0;i<5;i++){
Do this ;
}
we set our int i to 0 and after that there is a condition that returns us true of false or prity much compare our i against 5, because we want our code to execute 5 times .and the last thing is i++ which is incrementing i one by one.as long as our condition is returning us true, our code will be executeed and at the time when our condition i<5 returns us false (when i become 6) then our loop stops runnning.
see the example you will see how to use all the loops http://www.facebook.com/note.php?created&¬e_id=122384654503521
finally we are going through switch . when ever you have to cheack many conditinos say 100 conditions then instead of writing such nested conditions we use switch . see the example you will see why http://www.facebook.com/note.php?created&¬e_id=122387414503245 so see you soon guys. this is usman Signing off. Gud bye
nice
ReplyDelete