answersLogoWhite

0


Best Answer

if ( fork() ) {

print "hello";

}

else {

print "world";

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What must you place in if conditon to execute both if and else?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How If and else run at a time?

The standard syntax is:if( conditional_expression )statement;[[else if( conditional_expression )statement;[else if...]]else statement;][] denotes optional components. Each statement may be a single statement, or may be multiple statements surrounded by braces {}.The if( conditional expression ) statement; is the only required component. In plain English, this reads: if the conditional expression is true, then execute the following statement, otherwise skip to the line following the statement.If the next line is an else statement, then the line reads: if the conditional expression is true, then execute the statement and skip over the else statement. But if the conditional expression is false, then skip over the statement and execute the else statement instead.if( conditional_expression )statement; // execute when conditional expression is trueelsestatement; // execute when conditional expression is falseThe statement following the else can be another ifstatement (a nested if):if( conditional_expression_1 )statement; // execute when conditional_expression_1 is true.else if( conditional_expression_2)statement; // execute when conditional_expression_1 is false and _2 is true.elsestatement; // execute when both _1 and _2 are both false.Note that if an else statement is used without a following if statement, it must appear after all other else if statements.


What is the condition that executes both if and else part in c or c plus plus?

The only way that can happen is if a condition is both true and false at the same time. There is no such condition, so either the if or the else statements will execute for a given condition, but never both.


What is difference between IF THEN and IF THEN ELSE statement?

An if-then statement, or simply an if statement, checks if a stated condition is true. If the condition is true, then a block of code will then execute. Example: if number equals 3 print out "Number equals 3" An if-then-else statement, or simply an if-else statement, checks if a stated condition is true. If the condition is true, then a certain block of code will then execute. If the condition is false, then a different block of code will then execute. Example: if number equals 3 print out "Number equals 3" else print out "Number does not equal 3" For both if statements and if-else statements, there is only one stated condition. The difference between them is that an if statement will only cause something to happen if the condition is true. An if-else statement will execute a block of code whether the condition is true or false.


Is chicken imported or exported?

It's both, of course. If some place is importing it, some place else has to be exporting it.


Do you as wife have the right to change your husband power of attorney given to your son in 1997?

No. A person must execute their own POA. You cannot execute a POA for someone else.


What should be given at in if printf hello else world to get the output helloworld that is to make both the statements in ifelse clause to execute what should be given in if clause?

main() { if( !fork() ) printf("Hello"); else printf("World"); } This works fine. if (!printf("hello")) printf("Hello"); else printf(" World\n");


What accurately describes the grammar of a conditional-statement in c plus plus?

if (conditional_statement) {//Code to execute if true}if (conditional_statement) {//Code to execute if true} else {//Code to execute if false}if (conditional_statement) {//Code to execute if true} else if (another_conditional_statement) {//Code to execute of the second conditional statement is true} else {//Code to execute if neither statement is true}There are a few things to note about if statements that might be helpful:You can have as many 'else if' declarations in an 'if' statement as you want (These are called stacked if's)You can specify an if statement without the curly braces ('{' and '}') if there is only one line of code. For example: if (x > 10) x = 0;This will set x back to 0 if it is greater than 10, just like a normal 'if' statement but without the curly braces.As a result of this, 'else if', to the compiler, is not special at all. An 'if/else-if/else' statement is actually just two 'if/else' statements stacked on top of one another, where the 'else' doesn't have curly braces (hence the term "stacked if statement"). To demonstrate, the following two if statements are actually interpreted exactly the same by the compiler:if (x -10) {x = 0;} else {x++; //Increment x;}}


How do you find out what the correct cyntax for a particular dos command is?

Just execute it.. If it is write it will give you the result else error message..


What is the syntax of a conditional statement in JavaScript?

In JavaScript we have the following conditional statements:if statement - you would use this statement to execute some code only if a specified condition is trueif...else statement - you would use this statement to execute some code if the condition is true and another code if the condition is falseif...else if....else statement - you would use this statement to select one of many blocks of code to be executedswitch statement - you would use this statement to select one of many blocks of code to be executedFor example: If StatementUse the if statement to execute some code only if a specified condition is true. Syntaxif (condition) {code to be executed if condition is true}If...else StatementUse the if....else statement to execute some code if a condition is true and another code if the condition is not true. Syntaxif (condition) {code to be executed if condition is true}If...else if...else StatementUse the if....else if...else statement to select one of several blocks of code to be executed. Syntaxif (condition1) {code to be executed if condition1 is true}else if (condition2){code to be executed if condition2 is true}else{code to be executed if condition1 and condition2 are not true}else{code to be executed if condition is not true}


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 && *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 "ptr != nullptr" is evaluated twice when ptr is valid and refers to a non-zero value. The nested if only evaluates this expression one time.


When In TV programme lost The Execute button in the hatch needs to be pressed every?

every 108 minutes or else the island will emit an electromagnetic force which will attract metal from miles around, which is how the plane crashed in the first place, as desmond did not push the button


Who else help Hitler to execute all Jews?

Himmler, Heydrich and Eichmann are very notorious names. They have many deads on their mind.