answersLogoWhite

0

if (i<0) if (j<0) printf ("i<0 and j<0");

else printf ("What's now? Where this else belongs to? It's i>=0 or i<0 and j>=0?");

The answer is:

if (i<0) if (j<0) printf ("i<0 and j<0");

else printf ("i<0 and j>=0");

Of course you can use brackets:

if (i<0) {

if (j<0) printf ("i<0 and j<0");

else printf ("i<0 and j>=0");

}

or

if (i<0) {

if (j<0) printf ("i<0 and j<0");

} else printf ("i>=0");

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

What is the if statement that appears inside another if statement?

nested if Statement


What is nesting in C programming?

Nesting can be a very handy tool in C++, but should be avoided if possible.C++ gives us If statements, For loops and many other things. These can be nested. For example:A nested If statement://outer if statementIf( this is true ){//nested if statementif( this is also true ){//do something}else{//do something else}}


What does it mean to evaluate cobol?

The word evaluate in the programming language COBOL can be used to replace a nested if statement. Instead of long statement evaluate allows one to shorten the coding required and write cleaner code.


In which of the following scenarios would you need to use a nested IF statement?

You use a nested if when the condition is dependent upon another condition. For example: if (ptr != nullptr) { // ptr is non-null -- test the value it refers to if (ptr* == 0) { // the value pointed to by ptr is zero } else { // the value pointed to by ptr is non-zero } } In this case, the alternative to a nested if creates an inefficiency: if (ptr != nullptr &amp;&amp; *ptr == 0 ) { // ptr is valid and refers to the value zero } else if (ptr != nullptr) { // ptr is valid and refers to a non-zero value } In this example, the expression &quot;ptr != nullptr&quot; is evaluated twice when ptr is valid and refers to a non-zero value. The nested if only evaluates this expression one time.


What are A series of nested if statements is also called?

A series of nested if statements is also called a &quot;conditional structure&quot; or &quot;nested conditionals.&quot; This programming construct allows for multiple conditions to be evaluated in a hierarchical manner, where each if statement can contain additional if statements within its block. This approach helps in making decisions based on complex criteria by checking conditions in a structured way. However, excessive nesting can make the code harder to read and maintain.

Related Questions

What is the definition of 'nested' in C programming?

In C a structure within a structure is called nested. For example, you can embed a while loop in another while loop or for loop in a for loop or an if statement in another if statement.


What is the if statement that appears inside another if statement?

nested if Statement


Can you provide an example of a question that includes the keyword "negating nested quantifiers"?

An example of a question that includes the keyword &quot;negating nested quantifiers&quot; could be: &quot;Explain how to negate the statement 'For every x, there exists a y such that P(x, y)' in terms of nested quantifiers.&quot;


What is nesting in C programming?

Nesting can be a very handy tool in C++, but should be avoided if possible.C++ gives us If statements, For loops and many other things. These can be nested. For example:A nested If statement://outer if statementIf( this is true ){//nested if statementif( this is also true ){//do something}else{//do something else}}


How do you write a Program of printing prime numbers between 1 to 100 in 1 statement only?

You really need some nested loops; but some programming languages might allow you to write this as one statement.


What does it mean to evaluate cobol?

The word evaluate in the programming language COBOL can be used to replace a nested if statement. Instead of long statement evaluate allows one to shorten the coding required and write cleaner code.


When do you use the nested if?

we use "nested if" if we have to test a large number of possibilities and trials i an if statement.


Syntax of nested if in c?

If(condition) { if-else statement; } else { if-else statement; }


Can you have nested switch statement inc language?

yes,we can


Would you be correct in saying that in an nested if statement it would read ----if and it is and it is then do this--- else do this?

What you are asking would be not be a nested if then else statement, in pseudocode what you are asking would be:if condition thendo thiselsedo that[this is pseudo code because the 'and' would be rendered differently in other languages and there potentially would be statement terminators, etc]A nested if statement would be:if condition1 thenif condition2 thendo thiselsedo thiselsedo thatThe second if statement is nested within the first one, clearly the nesting can go on quite deeply.


What does nial mean?

It is a high-level programming language: Nested Interactive Array Language.


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.