Hello Friend !! Today I am going to tell u about decision making statement and branching in C#....
Decision Making & Branching Statement !!
A C# program is a set of statements that are normally executed sequentially in the order in witch they appear.We will study this concept one by one.These are mainly three type which is as given below..
- Branching Statement (simple if,if-else,Nested if...else,else if ladder ,switch statement).
- Jumping Statement (go to label,continue break)
- Looping.(while,do-while,for)
Firs we will study about branching statement which is as given below...
Branching Statement:=>
When a program break the sequential flow and jumps to another part of the code is called branching statement.
Decision making Statement with Simple If Statement:=>
The if statement is a powerful -making statement and is used to control the flow of execution of statements.Its two way decision statement and is used to in conjunction with an expression.
if(expression )
It allow the computer to evaluate the expression first and then depending on whether the value of the expression is true or false.The program at this point has two paths to follow one for the true condition and the other for the false condition.
some example of the decision making using if statement are:
1)if(bank balance is zero)
borrow money
2)if(room is dark)
put on lights.
The syntex of the simple if statement :
if(boolean expression)
{
statement block;
}
statement-x
Description:The 'statement-block' may be a single statement or a group of statements.If the boolean-expression is true then the statement-block will be executed otherwise the statement -block will skipped and the execution will jump to the statement-x
Example:
{
int value =10/5;
if(value ==2)
{
console.write(true);
}
Output:
true
The flow chart of simple if statement:=>
Now ! You can download the copy of the article in pdf file by just click on below download link...
If still You have any query regarding to this article then please post your comment i will 100% reply back you…..Thanks……:)