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 the advantage of using #define to declare a constant?
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none
How do you list files in a directory?
Do character constants represent numerical values?
How can I send mail from within a c program?
Compare array data type to pointer data type
What is the difference between the expression “++a” and “a++”?
Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58
Write a program on swapping (100, 50)
What is s in c?
what type of questions arrive in interview over c programming?
What are 'near' and 'far' pointers?
What is main return c?
Suggesting that there can be 62 seconds in a minute?
What is the g value paradox?