Computer Science, asked by Harshi666, 1 year ago

Mention one statement each to achieve:
1. Bi-directional flow of control
2. Multiple branching of control

(with reference to java programming)

Answers

Answered by nitish8089
33
Bi-directional....

use if ,else flow control...

Example:

if(condition) {
//statement
}
else{

//statement

}


2. Multiple branching of control...

using: if, else if flow control or switch.

Example:

if(condition) {

//statement

}

else if(condition){

// statement

}

.
.
.
.
.
.
else{

// statement

}
____________________________________

Example:

switch(){
.
.
.
.
}

nitish8089: thnk u for asking this question...
Harshi666: how did it help u??
nitish8089: read out some new concept and term...
Harshi666: oh
Harshi666: so welcome and thanks for your help
snehaswain36: Thanx u nitish for the answers.......
Answered by poojan
9

We can achieve the given goals/decisions using Conditional Statements in Java Programming.

We have four decision statements in java, namely:

1. if statement   (Single directional flow statement)

2. if... else statement (Bi-directional flow statement)

3. else if statement (Multi-directional flow/branching statement)

4. Switch statement (Multi-directional flow using cases)

1. Bi-directional flow of control:

if...else statement:

if (condition)

    {

      // code will be executed if the 'if condition' becomes true.

    }

else

    {

      // code will be executed if the 'if condition' becomes false.

    }

Example (Rough Skeleton of if...else statement in java)

int age=12;

if (age>=18)      //12>=18 -> Condition becomes false. diverts to else block

   {

      System.out.println("Major");

   }

else

   {

      System.out.println("Minor");    

     //if condition fails, the code in else block executes.

   }

//Results 'Minor' as output.

2. Multiple branching of control:

else if statement:

if (condition1)

  {

     // condition1==True -> executes if block

  }

else if (condition2)

  {

    // condition1=False and condition2=True -> executes else if block

  }

else

  {

    // condition1=False and condition2=False -> executes else block

  }

Example (Rough Skeleton of else if statement in java)

int marks=62;

if (marks<=50)     //62<=50 -> false -> goes to else if

 {

   System.out.println("Better luck next time!");

 }

else if (marks>=51 && marks<=80)   //62>=51 && 62<=80 -> true

 {                                                           //executes this block.

   System.out.println("Good!");

 }

else

 {

   System.out.println("Excellent!");

 }

//Prints 'Good!' is output.

Learn more:

   

1. A CSS file cannot be linked to a web page. State True or False.

brainly.in/question/21107345

2. True or false: to join two strings,use the dollar ($) character.

brainly.in/question/21624446

Similar questions
Math, 1 year ago