473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

tricky output ???

#include<stdio.h>
int main(void){
int i=5;
printf("%d %d %d %d %d\n",i++,i--,++i,--i,i);
return 0;
}
This gives me : 4 5 5 5 5

How ???

Can anyone please give me some hint as to why I am getting this ??

Thanks & regards,
Onkar

Feb 16 '08 #1
10 1875
onkar said:
#include<stdio.h>
int main(void){
int i=5;
printf("%d %d %d %d %d\n",i++,i--,++i,--i,i);
return 0;
}
This gives me : 4 5 5 5 5

How ???

Can anyone please give me some hint as to why I am getting this ??
What answer were you expecting, and why?
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Feb 16 '08 #2
On Feb 16, 11:17 am, Richard Heathfield <r...@see.sig.invalidwrote:
onkar said:
#include<stdio.h>
int main(void){
int i=5;
printf("%d %d %d %d %d\n",i++,i--,++i,--i,i);
return 0;
}
This gives me : 4 5 5 5 5
How ???
Can anyone please give me some hint as to why I am getting this ??

What answer were you expecting, and why?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

I was expecting 4 5 5 4 5
Feb 16 '08 #3
onkar <on*******@gmail.comwrites:
#include<stdio.h>
int main(void){
int i=5;
printf("%d %d %d %d %d\n",i++,i--,++i,--i,i);
return 0;
}
This gives me : 4 5 5 5 5
[...]

The FAQ for this newsgroup is at <http://www.c-faq.com/>.

You desperately need to read section 3. (Then read the rest of it.)

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Feb 16 '08 #4
onkar wrote:
#include<stdio.h>
int main(void){
int i=5;
printf("%d %d %d %d %d\n",i++,i--,++i,--i,i);
return 0;
}
What's brought all these daft UB questions out of the woodwork this week?

--
Ian Collins.
Feb 16 '08 #5
Ian Collins said:
onkar wrote:
>#include<stdio.h>
int main(void){
int i=5;
printf("%d %d %d %d %d\n",i++,i--,++i,--i,i);
return 0;
}
What's brought all these daft UB questions out of the woodwork this week?
What makes you think there's anything special about this week? :-)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Feb 16 '08 #6
On Sat, 16 Feb 2008 01:04:31 -0600, Ian Collins wrote
(in article <61**************@mid.individual.net>):
onkar wrote:
>#include<stdio.h>
int main(void){
int i=5;
printf("%d %d %d %d %d\n",i++,i--,++i,--i,i);
return 0;
}
What's brought all these daft UB questions out of the woodwork this week?
New semester started recently.

--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw

Feb 16 '08 #7
Richard Heathfield <rj*@see.sig.invalidwrites:
onkar said:
>#include<stdio.h>
int main(void){
int i=5;
printf("%d %d %d %d %d\n",i++,i--,++i,--i,i);
return 0;
}
This gives me : 4 5 5 5 5

How ???

Can anyone please give me some hint as to why I am getting this ??

What answer were you expecting, and why?
it should be blatantly obvious why he doesn't think this is right. The
fact he would be wrong is besides the point.
Feb 16 '08 #8
onkar wrote:
#include<stdio.h>
int main(void){
int i=5;
printf("%d %d %d %d %d\n",i++,i--,++i,--i,i);
return 0;
}
This gives me : 4 5 5 5 5

How ???

Can anyone please give me some hint as to why I am getting this ??

Thanks & regards,
Onkar
This guy is doubtless a troll. He keeps posting such stupid questions
even after months of being told about the FAQ.

Feb 17 '08 #9
Richard wrote:
>
Richard Heathfield <rj*@see.sig.invalidwrites:
onkar said:
#include<stdio.h>
int main(void){
int i=5;
printf("%d %d %d %d %d\n",i++,i--,++i,--i,i);
return 0;
}
This gives me : 4 5 5 5 5

How ???

Can anyone please give me some hint as to why I am getting this ??
What answer were you expecting, and why?

it should be blatantly obvious why he doesn't think this is right. The
fact he would be wrong is besides the point.
But, until one starts to think about "why" he thinks the answer
should be what he thinks it should be, you cannot explain to him
the flaws in his thinking.

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Feb 17 '08 #10
Kenneth Brody said:
Richard wrote:
>>
Richard Heathfield <rj*@see.sig.invalidwrites:
onkar said:

#include<stdio.h>
int main(void){
int i=5;
printf("%d %d %d %d %d\n",i++,i--,++i,--i,i);
return 0;
}
This gives me : 4 5 5 5 5

How ???

Can anyone please give me some hint as to why I am getting this ??

What answer were you expecting, and why?

it should be blatantly obvious why he doesn't think this is right. The
fact he would be wrong is besides the point.

But, until one starts to think about "why" he thinks the answer
should be what he thinks it should be, you cannot explain to him
the flaws in his thinking.
In fact, his answer to my question gave me a clue as to what he was
thinking. He might equally have said: 5 6 6 5 5, in which case my answer
would have been slightly different.

As usual, Richard Riley is sniping ignorantly, caustically, and
uncomprehendingly at people who are actually supplying help, instead of
taking the risk of supplying help himself to those who are asking for it.
He may safely be ignored, since he never contributes anything useful.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Feb 17 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Steve Jorgensen | last post by:
Hi all, I'm working on the schema for a database that must represent data about stock & bond funds over time. My connundrum is that, for any of several dimension fields, including the fund name...
3
by: rene | last post by:
Hello everybody, i have these 2 xml files ------1.xml------ <?xml version="1.0" encoding="UTF-8"?> <root> <element>1</element> <element>2</element> </root>
6
by: Jean-Gael GRICOURT | last post by:
I am trying to use ostringstream in binary mode. Why the value (0x0A) is automatically replaced by (0x0D,0x0A) in the output ? Is there a workaround to this issue ? -------- my snippet code...
4
by: joebob | last post by:
The following script if run in Internet Explorer should display a thumbview of a webpage that you point it to. To test it, replace test.htm with a valid html file. The problem I'm having is that...
3
by: Chris Capel | last post by:
I want to do something along the lines of this: class someclass { static void Main() { int i = 5; int j = 3; changevalue(ref i, j); Console.WriteLine(i.ToString()); //I want this to output 3...
2
by: pruebauno | last post by:
I am currently working on a tricky problem at work. I googled around a bit, but "time intervals" did not come up with anything useful. Although I have some rough idea of how I could solve it, I...
2
by: torpecool | last post by:
Hello Everyone, I have a situation that I just cannot wrap my head around. I would appreciate any ideas or suggestions. I am trying to parse and load a tab delimited file into a mysql...
9
by: nirkheys | last post by:
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...
7
by: wraithzshadow | last post by:
hello, I'm trying to code a form that will output all data on from one table into separate pages (can scroll through them using the arrows, or entering a specific entry at the bottom), but on each...
2
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I have a string containing this information: Including file: Myfile.fle (C:\Program Files\Application\Source\Myfile.fle) After myfile.fle there are three spaces! Since i use the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.