IntroductionThe concept of a computer program as a set of instructions that are executed one by one in order is familiar to anyone starting to code. This definition, although useful for introductory purposes, does not consider the frequent need for decision making. If we keep in mind that any useful software will invariably need to do this, we will have a better understanding of what a computer program is today. Show
To illustrate how to execute different portions of code based on a variety of conditions, in this guide we will use the
For simplicity, variables have hardcoded values in the following examples. However, in a real-world application, they are set as the end user interacts with the program by clicking on checkboxes, or entering text in a box, to name two examples. Introducing if / else ConstructsPicture the following scenario. You need to determine the eligibility of a job applicant based on his or her acceptance of your company's terms and policies. If the person answers yes, the hiring process may continue. Otherwise, a polite message stating that the application cannot be processed is shown. To address this, type the following code inside the
csharp When executed, the above code should produce the output shown in Fig. 1: Let us examine in detail what the program is doing:
Now, let us consider another scenario. Let us suppose we are using our code to test temperature ranges and perform the following actions:
We will follow essentially the same structure as before, only adding an
csharp
To summarize, use an Testing Multiple Conditions with Switch and CaseAlthough you can use as many To begin, we will type the
csharp We can potentially implement the same solution as above with the following code, but you will note that it is not as easy to read - let alone if there were more alternatives to check:
csharp So, if the result is the same, the question inevitably arises. When should we use a regular SummaryAs you can see, you can learn programming concepts using familiar things and processes, and then easily apply that knowledge to a wide variety of scenarios and more importantly, to your specific needs. Additionally, you can always consult the if-else and switch-case reference in the Microsoft documentation site. What is not one of the tasks that the devices and printers utility can be used for?What is NOT one of the tasks that the Devices and Printers utility can be used for? Identifying resource conflicts between devices. What Registry key contains information about the desktop setup for the account presently signed in to the server console?
Which of the following is a requirement for using storage spaces direct?Storage Spaces Direct requires 2 and up to 16 Microsoft-approved servers with direct-attached SATA, SAS, NVMe, or persistent memory drives that are physically attached to just one server each. Each server must have at least two solid-state drives, and at least four more drives.
Where can the most up to date list of compatible hardware available for Windows?You can find the up-to-date list of compatible hardware for Windows Server 2019 on the Windows Server Catalog online.
|