The code is::::: if(condition)
Printf("Hello");
Else
Printf("World");
What will be the condition in if in such a way that both
Hello and world are printed in a single attempt?????? Single
Attempt in the sense... It must first print "Hello" and it
Must go to else part and print "World"..... No loops,
Recursion are allowed........................

Answer Posted / fazil

/* Solution 1: */

int main(int argc, char* argv[])
{
if( argc == 2 || main( 2, NULL ) )
{
printf("Hello ");
}
else
{
printf("World\n");
}
return 0;
}

/* Solution 2 (Only for Unix and Linux): */

int main(int argc, char* argv[])
{
if( !fork() )
{
printf("Hello ");
}
else
{
printf("World\n");
}
return 0;
}

Is This Answer Correct ?    4 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does the message "automatic aggregate intialization is an ansi feature" mean?

683


What is #line?

600


What are actual arguments?

638


to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?

1559


How do you do dynamic memory allocation in C applications?

621






Tell us bitwise shift operators?

587


Explain how do you search data in a data file using random access method?

687


if p is a string contained in a string?

1395


What is scope of variable in c?

548


i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me

1470


How can I sort a linked list?

626


What is the auto keyword good for?

612


Multiply an Integer Number by 2 Without Using Multiplication Operator

310


Differentiate between new and malloc(), delete and free() ?

657


What are the salient features of c languages?

616