Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > tricky output ???

Reply
Thread Tools

tricky output ???

 
 
Richard
Guest
Posts: n/a
 
      02-16-2008
Richard Heathfield <(E-Mail Removed)> writes:

> 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.
 
Reply With Quote
 
 
 
 
santosh
Guest
Posts: n/a
 
      02-17-2008
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.

 
Reply With Quote
 
 
 
 
Kenneth Brody
Guest
Posts: n/a
 
      02-17-2008
Richard wrote:
>
> Richard Heathfield <(E-Mail Removed)> writes:
>
> > 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: <(E-Mail Removed)>


 
Reply With Quote
 
Kenneth Brody
Guest
Posts: n/a
 
      02-17-2008
Ian Collins wrote:
>
> 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?


Perhaps a new semester started a few weeks ago, and the instructors
keep on bringing out the same tired "let's invoke UB" questions?

What I want to know is why the instructors ask these questions? I
somehow doubt that most of them are trying to teach about UB, but
instead are assuming that "all the world's a VAX". (Or whatever is
the 21st century equivalent. Perhaps "all the world's a Windows
system using MSVC"?)

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <(E-Mail Removed)>

 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      02-17-2008
Kenneth Brody said:

> Richard wrote:
>>
>> Richard Heathfield <(E-Mail Removed)> writes:
>>
>> > 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
a tricky if else(maybe not tricky but impossible) nirkheys@gmail.com C Programming 9 04-25-2006 06:13 PM
Tricky NAT config on a 1721 Dan Rice Cisco 2 08-01-2005 03:43 PM
Tricky AUTOLOAD behavior Jim Schueler Perl 1 08-25-2004 08:00 AM
OSPF & BGP interaction.. Tricky problem? or just stupid.. Kris Cisco 2 06-20-2004 04:01 PM
Tricky Question: Page_Load VB Programmer ASP .Net 3 06-30-2003 08:03 PM



Advertisments