Saturday 21 September 2013

If Else Statement


 Programming Dost always tries to give the easy and effective information about Programming.If statement is very frequently used in programming and it is very much similar in use in all most every language like if else statement c++, if else statement php, if else statement c programming and if else statement in VB.

If/else Structure
We have seen that the “if” structure executes its block of statement(s) only when the condition is true, otherwise the statements are skipped. The if/else structure allows the programmer to specify that a different block of statement(s) is to be executed when the condition is false. The structure of if/else selection is as follows.

If(condition){
            Statements; (if the condition is true these statements will be executed)
}else{
            Statements;(else these will be executed)
}
In C language
char name;
If(name ==”MyOnlineMela”){
                cout<<”You are Welcomed in My Online Mela”;
}else{
                cout<<”You have lost your way”;
}

In PHP we can write the above function as

If($name==”MyOnlineMela”){
                Echo “You are welcomed in My Online Mela”;
}else{
                Echo “You have lost you way”;

}

No comments:

Post a Comment