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
What is static and volatile in c?
What is fflush() function?
When should you not use a type cast?
Explain the difference between null pointer and void pointer.
What is an auto keyword in c?
Explain how do you generate random numbers in c?
What is the difference between ++a and a++?
What is uint8 in c?
What are the features of the c language?
There seem to be a few missing operators ..
What is a pointer in c?
What is the use of typedef in structure in c?
Explain what is the use of a semicolon (;) at the end of every program statement?
p*=(++q)++*--p when p=q=1 while(q<=6)
Is it fine to write void main () or main () in c?