What should be the so that the following code snippet prints ”Hello World”?
if( <condition> )
printf ("Hello");
else
printf("World");
Solution 1 - Using fork() system call
#include <stdio.h>
int main(void)
{
if(fork())
printf ("Hello ");
else
printf("World");
return 0;
}
Solution 2 - Using return value of printf() function
#include <stdio.h>
int main(void)
{
if(printf("Hello ") == 1)
printf ("Hello");
else
printf("World");
return 0;
}
Written by Munia Balayil
solution3:
ReplyDeletemain()
{
if(1)
printf("Hello");
goto ELSE;
else
{
ELSE:
printf("world");
}
}