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 difference between procedural and functional programming?
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
What are control structures? What are the different types?
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
What is a good way to implement complex numbers in c?
Was 2000 a leap year?
Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me
Why header file is used in c?
Why do we need functions in c?
What is #line in c?
Where static variables are stored in c?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
Is it fine to write void main () or main () in c?
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above