Question

In: Computer Science

C# Programming Explain in your own words how using the control selection ( decision) structure is...

C# Programming

Explain in your own words how using the control selection ( decision) structure is useful in programming in general. Provide Example

Solutions

Expert Solution

Control selection statements

They help in testing the conditions provided by the user

If a particular condition is true then it will execute some set of statements

If condition evaluates to false it will execute some other set of statements

Helps in making decisions based on some set of conditions

Used to control the flow of execution of statements

Some decision making structures are

If

If else

Nested if else

Switch

If statement has some set of Boolean expressions which are followed by some statements

Similarly each has it's own functions and can be used based on the program we are writing

I will execute the code and edit my answer

example of if :

using System;
namespace Demo {
  public class A {
     public static void Main(string[] args) {
       int c=7;
       if(c==7)
Console.WriteLine("Value is 7");
     }
  }
}

example of else :

using System;

namespace Demo {

public class A {

public static void Main(string[] args)

{

int c=7;

if(c==7)

Console.WriteLine("Value is 7");

else

{

Console.WriteLine("Value is not 7");
}

}

}

}

we can use elseif if we have more than 2conditions

switch example

namespace Constants {
public class swi {
 public static void Main(string[] args) {
  char grade = 'A';
  switch (grade) {
   case 'A':
    Console.WriteLine("A grade");
    break;
   case 'B':
    Console.WriteLine("B grade");
    break;
   
   default:
    Console.WriteLine("Failed");
    break;
  }
 }
}
}

Thus switch is used.Similarly we can add more cases based on the code.


Related Solutions

a. In your own words, define the concept of "Recursion" in terms of C++ programming. b....
a. In your own words, define the concept of "Recursion" in terms of C++ programming. b. In your own words, define the concept of "infinite recursion". c. In your own words, define "mutual recursion" as it pertains to C++ programming.
How is neural control of eye movements accomplished? Explain and give examples in your own words.
How is neural control of eye movements accomplished? Explain and give examples in your own words.
In your own words, explain how stock ownership relates to control for another company. Is some...
In your own words, explain how stock ownership relates to control for another company. Is some level of stock ownership automatically enough to give control? Why or why not? Also explain what the point is of consolidation entries. Why can’t we just add across the various figures for both companies, without adjustments, to get the the correct totals for the group?
Explain in your own words the Molecular structure for multi center molecules.
Explain in your own words the Molecular structure for multi center molecules.
Using your own words, explain how Siemens HMI output can be created.
Using your own words, explain how Siemens HMI output can be created.
Using a graph and in your own words, explain how a change in open market purchases...
Using a graph and in your own words, explain how a change in open market purchases affects money supply and the nominal interest rate.
1. Describe in your own words the structure of DNA. 2. Describe in your own words...
1. Describe in your own words the structure of DNA. 2. Describe in your own words how DNA makes copies of itself. (I.e. Describe DNA replication.). Protein synthesis involves two processes, transcription and translation. Describe in your own words how each process occurs. Transcription Translation
question 1 ) explain these eight determinants of customer restaurant selection in your own words? 1....
question 1 ) explain these eight determinants of customer restaurant selection in your own words? 1. Location 2. Menu item differentiation 3. Price acceptability and value 4. Decor and lighting 5. Portion sizes 6. Product quality 7. Service standards 8. Menu diversity
Using your own words, explain the purpose of using the reset instruction with CTU.
Using your own words, explain the purpose of using the reset instruction with CTU.
Using your own words, how are gender roles developed? please respond to that in your own...
Using your own words, how are gender roles developed? please respond to that in your own words
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT