Hi all,
I have been asked if the following is possible.
i googled for it,thought a lot about it and decided that it is
not possible,but i am posting it here in a hope of getting this
problem solved.
---------------------
if(x)
{
printf("Hello") ;
}
else
{
printf("world") ;
}Is there any value of x for which output would be Hello world?
-------------------------
Thanking you all in advance
Just Saurabh 9 1716 ni******@gmail. com said: Hi all,
I have been asked if the following is possible. i googled for it,thought a lot about it and decided that it is not possible,but i am posting it here in a hope of getting this problem solved.
--------------------- if(x) { printf("Hello") ; } else { printf("world") ; }Is there any value of x for which output would be Hello world?
Yes.
#define x printf("Hello ") == 42
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously) ni******@gmail. com wrote: Hi all,
I have been asked if the following is possible. i googled for it,thought a lot about it and decided that it is not possible,but i am posting it here in a hope of getting this problem solved.
--------------------- if(x) { printf("Hello") ; } else { printf("world") ; }Is there any value of x for which output would be Hello world?
No.
OTH, if somewhere you don't terminate output with '\n' or flush it, you
may see nothing at all.
If x can be anything ??
Give a printf statement which prints "hello" in the place of x.
And negate the whole thing. Put it as --> if ( !x ).
The printf will return 5 and the negation will make the condition fail
and the printf in the else part will work. It will print "hello world".
Regards,
arun.. ni******@gmail. com schrieb: Hi all,
I have been asked if the following is possible. i googled for it,thought a lot about it and decided that it is not possible,but i am posting it here in a hope of getting this problem solved.
--------------------- if(x) { printf("Hello") ; } else { printf("world") ; }Is there any value of x for which output would be Hello world?
------------------------- Thanking you all in advance
Just Saurabh
Perhaps you don't understand if/else...
it's just either .. or and not both :-)
arun wrote: If x can be anything ?? Give a printf statement which prints "hello" in the place of x. And negate the whole thing. Put it as --> if ( !x ). The printf will return 5 and the negation will make the condition fail and the printf in the else part will work. It will print "hello world".
Regards, arun..
Thanks a lot Arun.
You solved my problem.
Just Saurabh
arun wrote: If x can be anything ?? Give a printf statement which prints "hello" in the place of x. And negate the whole thing. Put it as --> if ( !x ). The printf will return 5 and the negation will make the condition fail and the printf in the else part will work. It will print "hello world".
Regards, arun..
Thanks a lot Arun.
You solved my problem.
Just Saurabh ni******@gmail. com wrote: Hi all,
I have been asked if the following is possible. i googled for it,thought a lot about it and decided that it is not possible,but i am posting it here in a hope of getting this problem solved.
--------------------- if(x) { printf("Hello") ; } else { printf("world") ; }Is there any value of x for which output would be Hello world?
#include <stdio.h>
#define x (printf("Hello "),fflush(stdou t),0)
int main(void)
{
printf("[output:]\n");
if (x)
printf("Hello") ;
else
printf("world") ;
putchar('\n');
return 0;
}
[output:]
Hello world
On 2006-04-25, ni******@gmail. com <ni******@gmail .com> wrote: Hi all,
I have been asked if the following is possible. i googled for it,thought a lot about it and decided that it is not possible,but i am posting it here in a hope of getting this problem solved.
--------------------- if(x) { printf("Hello") ; } else { printf("world") ; }Is there any value of x for which output would be Hello world?
Here's one:
#include <stdio.h>
int y = 1;
#define x (y-- ? main() : 1)
int main(void)
{
if (x)
printf("Hello\n ");
else
printf("World\n ");
return 0;
}
Richard Heathfield wrote: ni******@gmail. com said: I have been asked if the following is possible. i googled for it,thought a lot about it and decided that it is not possible,but i am posting it here in a hope of getting this problem solved.
--------------------- if(x) { printf("Hello") ; } else { printf("world") ; }Is there any value of x for which output would be Hello world?
Yes.
#define x printf("Hello ") == 42
A nice devious mind at work :-)
--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Also see <http://www.safalra.com/special/googlegroupsrep ly/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lars Plessmann |
last post by:
Problem: I try to store data in a objects field and read it out again.
Sounds easy, yeah. But its a bit tricky here.... ;-)
This is the class Customer.php with some setter and getter functions to
store customers data within an object.
It works.
Furthermore, it includes a synchronize method, which calls the
individual setXXX function and takes the data
from the $_POST or $_GET var.
|
by: Ron Adam |
last post by:
There seems to be a fair amount of discussion concerning flow control
enhancements lately. with, do and dowhile, case, etc... So here's my
flow control suggestion. ;-)
It occurred to me (a few weeks ago while trying to find the best way to
form a if-elif-else block, that on a very general level, an 'also'
statement might be useful. So I was wondering what others would think
of it.
|
by: why? |
last post by:
I've been having problem with the following code. It's supposed to
print the prime numbers between 10 and 100. But i'm not getting any
output, i.e. i guess the outer 'for' loop is being traversed only
once. I would be greatful if you could help me out. Thanx!
.... for j in range(2,i):
.... if i%j==0:
.... f=0
.... break
.... else: continue
.... if f==1:
|
by: joebenjamin |
last post by:
This is a problem I was trying to help a few friends figure out for fun. I
am not sure how to go about this, but there is something I am missing
here. Here is what we want the output to be:
Need to read in a time period from the keyboard (for example 1.2 seconds,
3.4 seconds, or 8.37 seconds). Once the time has been read in, we want to
print out the word “TICK” and then wait the designated time period and
print the word “TICK” again....
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |