Interesting C Question

Go4Expert Member
28Sep2007,18:17   #1
ndakota's Avatar
Code:
void main()
{
		 if(CONDITION)
			   printf("Hello ");
		 else
			   printf("World");
}
Replace CONDITION with such a condition that both the printf statements get executed.
You can't have a loop or other things in main()
According to my knowledge it's not possible.
But if it is possible, please let me know.
Thanks
Go4Expert Founder
28Sep2007,18:24   #2
shabbir's Avatar
printf("World"); would be nice option
Go4Expert Member
28Sep2007,18:28   #3
ndakota's Avatar
thaks
Team Leader
28Sep2007,19:49   #4
DaWei's Avatar
A single if-else with a condition cannot take both branches. It's not an interesting question, it's a silly question.
Go4Expert Member
1Oct2007,17:26   #5
An007kit's Avatar
condition --->if(!printf("hello"))
Go4Expert Member
1Oct2007,20:57   #6
An007kit's Avatar
Well dawei......that is not a silly question......actually that's a tricky question......
Team Leader
1Oct2007,21:54   #7
DaWei's Avatar
Nothing tricky about it. It's silly. Your amazing solution only has one printf statement so it can't possibly
Quote:
Originally Posted by original poster
such a condition that both the printf statements get executed.
That isn't a trick; that's being unable to read and comprehend.
Go4Expert Member
1Oct2007,22:01   #8
An007kit's Avatar
DaWei....there are still two printf statements that get get executed.....one that prints hello and other that prints world.......so i think there is no problem in reading neither in comprehension.....