answersLogoWhite

0


Best Answer

C++ if() statements implements a comparison and a jump opcode. By way of example, consider the following code:

if( x 100 ) generates a compare and jump opcode (cmp and jne).

The cmp opcode compares the value of x with 64h (100 decimal) which will either set or clear ZF (the zero flag). If x is 100, then ZF will be unset, otherwise it will be set.

The jne (jump if not equal) opcode tests ZF. If it is set, then x was not 100 and the operand (1181934h) is passed to the PC register (the program counter). The IR (instruction register) will fetch the value from PC on the next cycle. This ultimately causes execution to jump to the statement immediately following the else clause of the if statement (the second printf statement).

If ZF is not set, then x really was 100 and the PC register remains unaffected. At that point the PC register will contain the value 0118191Bh, which is the next instruction after the if statement, thus execution simply falls through to the first printf statement. After processing the printfinstructions, execution will reach the else clause which simply forces a jump to bypass the second printfstatement.

Thus, one of the printf statements is executed and then execution continues from the instruction at 118194Bh, which is not shown but is the next instruction after the second printfstatement.

User Avatar

Wiki User

βˆ™ 11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

βˆ™ 12y ago

A nested if is an if statement that is nested within another if statement.

int x=1, y=2;

if( x==1 )

{

if( y==1 ) // nested if.

{

// x==1 and y==1

}

else if( y==2 ) // another nested if.

{

// x==1 and y==2

}

else

{

if( y==1 ) // yet another nested if.

{

// x!=1 and y==1

}

else if( y==2 ) // and another nested if.

{

// x!=1 and y==2

}

}

This answer is:
User Avatar

User Avatar

Wiki User

βˆ™ 15y ago

A nested statement is one statement within another.

// If statement: if(true) { // Nested if statement:if(true) {} }

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What does if statements in c plus plus implement?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What c plus plus statements assign x the value 12?

x = 12;


What is the character used at the end of executable statements in C plus plus?

The semi-colon converts a C++ expression into a statement.


Write a program in c plus plus to implement macro processor?

Don't write, it is already written, google for 'cpp'.


What are the conditional statement of turbo c plus plus dos based?

Statements that check an expression then may or may not execute a statement or group of statements depending on the result of the condition.


What are unconditional statements in c plus plus?

Unconditional statements are statements that are invoked unconditionally. Conditional statements have a controlling expression, while unconditional statements do not. For example: void f (bool b) { if (b==true) do_something(); // conditional statement (controlled by the expression b==true) do_something_else(); // unconditional (executes regardless of b's value) }

Related questions

Control statement in c plus plus?

Control statements are statements that alter the flow of execution according to the evaluation of an expression (the condition). The C++ control statements are ifstatements, switch statements and the tertiary conditional operator, ?:.


What is the difference between statements in c plus plus charconstp and char constp?

There is no difference. Both statements are invalid.


How do you implement insertion into AVL tree in C plus plus?

See related links for an example.


What c plus plus statements assign x the value 12?

x = 12;


What is the character used at the end of executable statements in C plus plus?

The semi-colon converts a C++ expression into a statement.


How to make decision making statements in c plus plus?

Decision making statements make use of conditional expressions. In C++ there are three possibilities: if/else, switch/case and the ternary operator (?:).


Explain control instructions in c plus plus?

Control instructions are instructions that alter the flow of execution. In C++ this include if, if-else statements, switch-case statements and the conditional ternary operator (?:), as well as loop structures (for, while, do-while) and procedural goto statements.


What is stream operator in c plus plus?

There are two stream operators: << (insert or put) and >> (extract or get). Output streams implement the insertion operator, input streams implement the extraction operator and input/output streams implement both operators.


Write a program in c plus plus to implement macro processor?

Don't write, it is already written, google for 'cpp'.


What are the conditional statement of turbo c plus plus dos based?

Statements that check an expression then may or may not execute a statement or group of statements depending on the result of the condition.


Looping statement in c plus plus?

There are several 'looping' statements in C++. They are:while () { }do { } while () ;for (index-start, index-end; index increment/decrement) { }They are used to repetitively execute statements as long as the statement(s) controlling the loop are true.


What are unconditional statements in c plus plus?

Unconditional statements are statements that are invoked unconditionally. Conditional statements have a controlling expression, while unconditional statements do not. For example: void f (bool b) { if (b==true) do_something(); // conditional statement (controlled by the expression b==true) do_something_else(); // unconditional (executes regardless of b's value) }