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........................

Answers were Sorted based on User's Feedback



The code is::::: if(condition) Printf("Hello"); E..

Answer / gg

#include<stdio.h>
main()
{
if(printf("hello")==0)
printf("hello");
else
printf("world");
}

Think is there any Other.....

Is This Answer Correct ?    62 Yes 10 No

The code is::::: if(condition) Printf("Hello"); E..

Answer / abdur rab

#include <stdio.h>

int main ( int argc, char* argv[] )
{
if ( !printf("Hello") )
printf ("Hello");
else printf (" World");
}

Is This Answer Correct ?    17 Yes 6 No

The code is::::: if(condition) Printf("Hello"); E..

Answer / vignesh1988i

but goto is not a good sort of programming ............. a
well knowledgeable programmer wont use goto..... according
to me........... plz think of any other logic??????????

Is This Answer Correct ?    5 Yes 5 No

The code is::::: if(condition) Printf("Hello"); E..

Answer / vignesh1988i

but yhe printf statement will print one "hello" and one
world.......................... but i said it must enter to
the if part as well as else part controls..............
before a long time baxk itself i tried this method.........
then only i read the question of IBM properly

Is This Answer Correct ?    4 Yes 4 No

The code is::::: if(condition) Printf("Hello"); E..

Answer / anudyuti

#include <stdio.h>
int executeboth();
void main()
{
both();
}

int both()
{
static int i=0;
if(i++==0 ? executeboth():1)
{
printf ("Hello");

}
else
{
printf (" World");
}
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

The code is::::: if(condition) Printf("Hello"); E..

Answer / nisha

If(?)
printf("hello");
else
Printf("world");

Is This Answer Correct ?    0 Yes 0 No

The code is::::: if(condition) Printf("Hello"); E..

Answer / srikanth

int main()
{
if(fork())
{
printf("hello");
}
else
{
printf("world");
}
}

Is This Answer Correct ?    0 Yes 0 No

The code is::::: if(condition) Printf("Hello"); E..

Answer / dinakaran gct

#include<stdio.h>
void main()
{
if(1)
{
printf("HELLO!");
goto HERE;
}
else
{
HERE:
printf("HAI....");
}
}

Is This Answer Correct ?    18 Yes 19 No

The code is::::: if(condition) Printf("Hello"); E..

Answer / subbu

#include<stdio.h>

int main()
{
if(!printf("Hello")
{
printf("Hello");
}
else
printf("World");
}

Is This Answer Correct ?    0 Yes 1 No

The code is::::: if(condition) Printf("Hello"); E..

Answer / 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

More C Interview Questions

what is the difference between exit() and _exit() functions?

2 Answers  


can we declare a function inside the structure? ex: struct book { int pages; float price; int library(int,float); }b; is the above declaration correct? as it has function declaration?

2 Answers  


How can I implement opaque (abstract) data types in C? What's the difference between these two declarations? struct x1 { ... }; typedef struct { ... } x2;

2 Answers  


Why can't we initialise member variable of a strucutre

1 Answers  


What is function and its example?

0 Answers  






What is the difference between union and anonymous union?

0 Answers   Hexaware,


1,1,5,17,61,217,?,?.

3 Answers   Apple,


There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.

1 Answers   HCL, iGate,


What is #include conio h?

0 Answers  


if ENTERED FIVE DIGITS DESIGN A PROGRAM THAT WILL FIND CORRESPONDING VALUE FROM ASCII TABLE

1 Answers  


How can I make a program in c to print 'Hello' without using semicolon in the code?

9 Answers   C DAC, Practical Viva Questions,


#include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); } what is the output for this?

4 Answers   IIIT,


Categories