1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alinara [238K]
3 years ago
10

Different between if/else structure and switchstructure in c and c++, why switch statements is more efficientthan using multiple

if/else statements?
Computers and Technology
1 answer:
ad-work [718]3 years ago
7 0

Answer:

Explanation:

Hello, great question. These types are questions are the beginning steps for learning more advanced Coding Problems.

If/Else statements receives an input and compares it to a true of false statement, if it is true then one function is called. Otherwise another function is called. IF/Else statements only have two outcomes which is why they are many times nested one on top of the other to be able to produce more outcomes.

Switch Statements receive and input and compares it to a set of predefined answers. If the right answer is found then the function relating to that answer is called. Otherwise the default function is called.

IF/Else is only more efficient than Switch statements if the inputted value is not predictable enough to make a predefined set.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

You might be interested in
Two files named numbers1.txt and numbers2.txt both have an unknown number of lines, each line consisting of a single positive in
Reika [66]

Answer:

see explaination for program code

Explanation:

scalar_product = 0

li=[]

li2=[]

#reading numbers1.txt and numbers2.txt intoli and li2 respectively

with open('numbers1.txt') as n1, open('numbers2.txt') as n2:

for line1 in n1:

li.append(int(line1))

for line2 in n2:

li2.append(int(line2))

#storing min list size into variable l

a=len(li)

b=len(li2)

if a<b:

l=a

else:

l=b

#calculating scalar product

for i in range(l):

scalar_product=scalar_product+li[i]*li2[i]

print("scalar product is",scalar_product)

6 0
3 years ago
Which of the following statements is true? Methods and instance variables can both be either public or private. Information hidi
Alex777 [14]

Answer:

B

Explanation:

8 0
3 years ago
A fast-food restaurant has four kinds of employees:
Marysya12 [62]

Answer:

Following is given the detailed solution of the given question.

I hope it will help you!

Explanation:

7 0
3 years ago
There are five identical closed boxes. one box contains $10,000, two boxes contain $1000 each, one box contains $1, and the last
sp2606 [1]
Mean means most and the most he can get is the 10000 and the 2 1000s and the 1 dollar so the mean is 12001.
6 0
4 years ago
coding could help prevent car crashes with automatic driving cars; however, some are afraid of tha because it allows control ove
dybincka [34]

Answer:

Honestly self driving cars are the future of humans and it can and will help us evolve. It could possibly be more dangerous if someone messed up the coding and it can be hacked by almost anyone with coding abilities, so it all depends on how safe you think you will be not driving yourself anywhere. Overall it could go both ways( good or bad.)

Hope this helped

Explanation:

5 0
4 years ago
Other questions:
  • A _______________ is a field that contains data unique to a record.
    15·1 answer
  • Conceptual note-taking is the act of
    15·1 answer
  • A user can easily moved to the end of document by pressing what key combination?
    8·2 answers
  • You were replying to e-mail when suddenly your computer started to display random messages, and stopped responding to keyboard a
    10·1 answer
  • What type of function is the IF function?<br> Statistical<br> Logical<br> Financial <br> Text
    5·2 answers
  • What is a directory server?
    5·1 answer
  • A negative effect of computer technology's role in creating images is that:
    13·2 answers
  • How can the function abcfunc change the address in its local copy of intpoint?
    11·1 answer
  • Many bookstores have closed since the rise of the Internet. What type of
    11·1 answer
  • I have this questions i need to make it in a report format pages of atleast 3 pages and maximum of 5 pages​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!