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

write an interactive C program that will encode or decode a line of text.To encode a line of text,proceed as follows. 1.convert each character,including blank spaces,to its ASCII equivalent. 2.Generate a positive random integer.add this integer to the ASCII equivalent of each character.The same random integer will be used for the entire line of text. 3.Suppose that N1 represents the lowest permissible value in the ASCII code,and N2 represents the highest permissible value.If the number obtained in step 2 above(i.e.,the original ASCII equivalent plus the random integer)exceeds N2,then subtract the largest possible multiple of N2 from this number,and add the remainder to N1.Hence the encoded number will always fall between N1 and N2,and will therefore always represent some ASCII character. 4.Dislay the characters that correspond to the encoded ASCII values.  The procedure is reversed when decoding a line of text.Be certain,however,that the same random number is used in decodingas was used in encoding.

0 Answers  


What are identifiers in c?

0 Answers  


write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)

0 Answers   Google,


what is the use of #pragma pack, wer it is used?

2 Answers   Wipro,


what is use of loop?

10 Answers   Infosys,






User define function contain thier own address or not.

2 Answers  


What tq means in chat?

0 Answers  


Why pointers are used?

0 Answers  


what is the advantage of using SEMAPHORES to ORDINARY VARIABLES???

2 Answers   NSN,


can we declare a function in side the structure?

2 Answers   HCL,


Explain what is the use of a semicolon (;) at the end of every program statement?

0 Answers  


Where local variables are stored in c?

0 Answers  


Categories