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 are all different types of pointers in c?
Explain is it valid to address one element beyond the end of an array?
If I have a char * variable pointing to the name of a function ..
What is linear search?
write a program to print data of 5 five students with structures?
Do pointers store the address of value or the actual value of a variable?
Declare the structure which contains the following members and write in C list of all students who score more than 75 marks. Roll No, Name, Father Name, Age, City, Marks.
Tell me what is null pointer in c?
What is a static function in c?
Is javascript based on c?
What is a structural principle?
How can I write functions that take a variable number of arguments?
When should a type cast be used?
Explain what is a pragma?
Can you think of a logic behind the game minesweeper.