answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: What benefit does the enhanced for statement provide for array processing what are its limitations?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Why are the indents necessary after the if and else statement?

Indents are not necessary for simple if statements: if (true) /* do something */ ; else /* do something */; However, when a statement is a compound statement, it's best to place the statement body on a separate line and indent it: if (true) { /* do something */ ; /* do something */ ; /* do something */ ; } else { /* do something */; /* do something */; } The indents help the reader; separating the controlling expressions from the compound statements and thus exposing the structure of the if statement itself.


How far can poorer countries benefit from scientific technology?

Poor countries can benefit from a limited amount of scientific technology. They do not have the resources to utilize higher levels of technology, but they can benefit from things that improve the quality of food production, health care, and sanitation.


What is the syntax and purpose of the switch statement in c plus plus?

The purpose of a switch statement is to execute one of several sections of code, depending on the value of an integral expression. The syntax of a switch statement can be stated as follows: switch(expression) { case(constant_expression_1): statement case(constant_expression_2): statement //.. case(constant_expression_n): statement [default: statement] } The ellipses around the constant expressions are optional and may be omitted. The switch statement body consists of one or more case labels and an optional default label (the case labels are also optional, but a switch statement would be meaningless without them). The default statement, if present, need not be the final label in a switch statement. Case and default labels may not appear outside of a switch statement, as they are not treated the same as goto labels. The constant_expression in each case label is converted to the type of the switch expression and is compared with the switch expression for equality. Control is immediately passed to the labelled statement whose constant_expression matches the value of the switch expression. Once a label gains control, execution proceeds from that point on and is not impeded by any subsequent case or default labels. However, a break statement may be used to interrupt execution at any time, which will transfer control to the statement immediately following the switch statement body. You may also use a return statement to return control to the calling function, or a goto statement. However, note that while a goto label is not the same as a case label, you may use goto labels inside a switch statement if required. Here's an example demonstrating how code flows through a switch statement: int x; switch(x=rand()%10) // x is a random number in the range 0 to 9. { case(0): x=42; break; case(1): case(2): x=33; break; case(3): x=100; default: x=0; } If x were 0, then execution passes to case(0) where the value 42 is assigned to x and the switch exits. If x were 1 or 2, then 33 is assigned to x and the switch exits. If x were 3, 100 is assigned to x. In all other cases, 0 is assigned to x. You will note that when the switch statement ends, x can only ever be 42, 33 or 0. Why not 100? Look again and you will see that case(3) has no break statement (just as case(1) has no break statement). So although 100 is assigned to x in case(3), the default case immediately assigns 0 to x. This is not a particularly useful switch statement, but it serves to demonstrate how code flows through a switch statement, and how forgetting to put a break statement at the end of a case can cause unexpected errors to creep into your code. While you could emulate the same results using a series of if, else if and else statements, the benefit of a switch statement is that it will generally simplify the complexity of your code, because there is only one expression to evaluate, rather than a series of boolean expressions. Your compiler will generate machine code just as if you'd used a series of if statements, but the switch statement gives a greater sense of structure to the statement, and gives a greater degree of control over which section(s) of code will execute for any given evaluation. And just as ifs can be nested within other ifs, switch statements can be nested within other switch statements. Note that all code in a switch statement must be reachable (that is, not bypassed by all execution paths). For instance the following contains both unreachable and undefined code: switch(x) { x=42; //unreachable case(100): int y=42; break; default: x=y; // y is undefined } The line x=42 cannot be reached because execution must either pass to either the case(100) or the default label. Similarly, the x=y line is invalid because y is defined within the case(100) label, which is not reachable from within the default label due to the break statement.


What is a benefit of desalination technology?

Fresh drinking water


How can technology benefit your personal career needs?

This is from Cole Hillhouse. Techology can benefit your career and personal needs by helping you at a job or even in schooling. Technology has came a long way.

Related questions

WhAT Benefit of using computers at an airport?

enhanced security


What are the business benefit and limitations of Rick Dalzell's strategies?

high priority answer


What does FBO mean on a financial statement?

For Benefit Of


What are the benefit's and limitations of job order costing and process costing system?

to undersrand


What do you understand by cost-benefit analysis and what are its uses and limitations?

What do you understand by cost analysis


What does BCA1 mean on bank statement?

Child benefit


Explain how a tps implementaion would benefit the daily operation of the business and why would you recommend online processing in stores?

explain how a TPS implementation would benefit the daily operation of the business and why you recommend on-line processing in stores?


National response framework present the guiding principles that?

Select the statement below that best describes one benefit of NIMS


What is the benefit of just-in-time processing?

Minimizes storage space needed.reducing time and coast.


A benefit of using good human relations is that?

A benefit of using good human relations is that you are able to get more output. The human relations will ensure that people are motivated in the right way and efficiency is enhanced.


How would an online business benefit from using online credit card processing software?

An online business may benefit from using online credit card processing software in a variety of ways. Usually the biggest benefit is the large boost in sales as it makes the online business more attractive to a wider market.


Mission statement of Sony corporation?

Sony Mission Statement "To experience the joy of advancing and applying technology for the benefit of the public."