answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: Which control statement executes one of many blocks of code depending on the state of a variable?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the method used to implement an if else statement in C?

The else statement is an optional part of an if statement that is executed if the primary if condition is false.if (condition) true_statementelse false_statement


Explain goto and return in c?

A return statement is used to transfer the program control flow to the function that has called the current function under execution. If the function is main, then the program returns the control flow to the operating system. The syntax for return statement is:return return-type;A goto statement is used to transfer the control flow to a particular labelled statement, not necessarily back to the calling program. There are somerestrictionson using a goto statement. For eg: the goto statement should not skip any variable declarations. The use of goto statement is usually considered as a bad programming practice. The syntax for goto statement is:goto label_name;....label_name: statements;


Use the control variable during the execution of the loop?

Control variable which is used in control structures.e.g. for(int i=0;i


A variable declared inside the for loop control cannot be referenced outside the loop?

Yes. A variable declared inside the loop is a local variable for the code block enclosed by the {} statements of the for loop. The variable will not be available to be used by any code outside the code block.


Why you need a for loop when you have already while loop or do while loop?

We need a for loop because the while and do-while loops do not make use of a control variable. Although you can implement a counter inside a while or do-while loop, the use of a control variable is not as self-evident as it is in a for loop. Aside from the use of a control variable, a for loop is largely the same as a while loop. However, it is quite different to a do-while loop, which always executes at least one iteration of the loop before evaluating the conditional expression. In a for and while loop, the conditional expression is always evaluated before entering the loop, which may result in the loop not executing at all.

Related questions

What does an IF Statement do?

An if statement is a control statement. It is used to control whether a statement executes or not, depending on whether a control expression evaluates true or false.if (expression) {statement;}In the above example, the expression is evaluated. If true, the statement executes, otherwise it does not.if (expression) {statement1;} else {statement2;}In the above example, the expression is evaluated. If true, statement1 executes otherwise statement2 executes.Note that if statements may be chained together using else if statements. The final else clause (if present) then becomes the default case. Also, any statement within an if statement may itself be an if statement, known as a nested if. If statements may be chained or nested to any depth.


A statement of a possible relationship between the independent and dependent variables?

A dependent variable is a variable dependent on the independent variable. A control variable is something you want to try to keep the same. A dependent variable is something you measure. An independent variable is something you change.


What are the three actons a counter variable uses?

Variables don't have any "actions". A variable provides storage for a value, nothing more. A counter variable is typically used in a bounded for loop. A for loop has three clauses, each of which is optional. The first clause is the initialiser which can be used to initialise a control variable upon entry to a bounded loop. The second clause is the conditional expression which is evaluated at the start of each iteration. If that expression evaluates false, execution passes to the statement following the for statement, otherwise the body of the loop executes. The second clause is typically used to test the control variable is within the bounds of a bounded loop. The third clause is an operation that will be performed at the end of each iteration. In a bounded loop, this clause is typically used to increment the control variable. For example: for (int x=0; x<10; ++x) { /* ... */ } The above loop is a bounded loop that will execute the body of the loop 10 times. The control variable, x is first initialised to 0. At the start of each iteration, if x<10 is true, the body of the loop will execute one iteration. At the end of each iteration, the ++x statement increments x. When x is 10, the x<10 expression becomes false and execution passes to the statement immediately after the for loop.


What is control variable and manipulated variable?

a control variable is a variable that needs to be controlled


What are the similarities between a control and a variable?

There are not any similarities between a control and a variable. However, a Control Variable, is a variable.


What do controlled variable do?

You can control it that's why its called control variable.


The factor being measure in an experiment?

The dependent variable is monitored as the independent variable is changed. One is testing the effect of the independent variable on the dependent variable (ie effect of dissolved HClO on pH).


What is a control variable in research studies?

A control variable is a variable that is held constant in a research analysis.


What is the difference between a control variable and a control treatment?

what is the difference between a variable and a control


How do you control one variable at time?

who to control one variable at time


Is a variable that stays the same a constant independent variable or control?

Control


What is multiple branching in gwbasic?

In gw-basic, when program control is transferred depending on a certain condition, it is called conditional transfer of control. To transfer control from one point to multiple points is called multiple branching. Statement used in gw-basic for this purpose is ON.....GOTO. Syntax: ON numeric variable or expression GOTO n1, n2, n3,....... The range o value of numeric variable or expression is 0 t0 255. n1, n2 are valid line numbers where control will be transferred. If the value of numeric variable or expression is 1, the control will be transferred to line number n1, in case of 2 to n2 and so on.