Computers and Technology
Computers and Technology, 24.10.2020 14:00, door9817

Create a program that ask the user to enter the number of switches and calculates the possible outcomes that can come from those many number of switches (on / off).

Follow the steps given below to achieve the desired result:

● Step 1: Get the number of switches from the user and store it in a variable (lets

say switches).

● Step 2: Initialize 3 variables max_poss = 2, i = 1 and power = 1, where,

β—‹ max_poss = 2 denotes the maximum possibile outcome of 1 switch (i. e. on

and off),

β—‹ i is used to set the condition in while loop and it will keep incrementing

unless all the switches are over.

β—‹ power variable is further used to store the result.

● Step 3: Define a while loop with a condition to execute till the value of i is less

than or equal to switches.

● Step 4: Inside the while loop,

β—‹ Multiply the value stored in max_poss with power and store the result in

power.

β—‹ Increment the value of i by 1.

For eg: When switches = 2, In the

1st iteration, power = 2 and in the 2nd iteration, power = 2 * 2 i. e. 4. This indicates that, the

number of possible outcomes = 2switches, where switches denotes the number of

switches.

● Step 5: Print the total number of possible outcomes stored in variable power.
plss help me with this

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 14:40, davidb1113
You begin your first day of responsibilities by examining the recent is security breach at gearup to get ideas for safeguards you will take. at gearup, criminals accessed the company's improperly-secured wireless system and stole customers' credit card information as well as employee social security numbers. what kind of computer crime did gearup face?
Answers: 3
image
Computers and Technology, 22.06.2019 22:20, kaiyerecampbell95
Pp 4.1 design and implement a class called sphere that contains instance data that represents the sphere’s diameter. define the sphere constructor to accept and initialize the diameter and include getter and setter methods for the diameter. include methods that calculate and return the volume and surface area of the sphere (see pp 3.5 for the formulas). include a tostring method that returns a one-line description of the sphere. create a driver class called multisphere, whose main method instantiates and updates several sphere objects.
Answers: 1
image
Computers and Technology, 23.06.2019 18:00, taiyana74
Ramona enjoys her job because she is able to kids in an after school program. the work value ramona feels strongest about is a. leadership b. risk c. independence d. work with people select the best answer from the choices provided a b c d
Answers: 1
image
Computers and Technology, 24.06.2019 05:50, 11232003
What all vehicles has tesla inc. created over the years
Answers: 3
Do you know the correct answer?
Create a program that ask the user to enter the number of switches and calculates the possible outc...

Questions in other subjects:

Konu
Mathematics, 01.02.2021 21:00
Konu
Business, 01.02.2021 21:00
Konu
Mathematics, 01.02.2021 21:00
Konu
Mathematics, 01.02.2021 21:00