Go Back   Rhinocerus > Newsgroup > Newsgroup comp.language.c++

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-26-2009, 09:32 AM
dost
Guest
 
Posts: n/a
Default cant get the concept of this result

Guess the result and then write in ur editor

void DisplayInterestingRsult2(int a, int b)
{

printf("\n\tA[%d],B[%d]\n",a,b);
}


int _tmain(int argc, _TCHAR* argv[])
{

int iInput = 0;
printf("\ni = 0 FUN(i++,++i,i++,i)\n");
DisplayInterestingRsult(iInput++,++iInput,iInput++ ,iInput);
}




My result is

A[2]B[3]C[0]D[3]

i could not find why is it so.

please explain.

using of printf should be ignored you can use cout.
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 11-26-2009, 09:50 AM
dost
Guest
 
Posts: n/a
Default Re: cant get the concept of this result

On Nov 26, 3:32*pm, dost <kapilkaushik....@gmail.com> wrote:
> Guess the result and then write in ur editor
>
> void DisplayInterestingRsult2(int a, int b)
> {
>
> * * * * printf("\n\tA[%d],B[%d]\n",a,b);
>
> }
>
> int _tmain(int argc, _TCHAR* argv[])
> {
>
> * * * * int iInput = 0;
> * * * * printf("\ni = 0 FUN(i++,++i,i++,i)\n");
> * * * * DisplayInterestingRsult(iInput++,++iInput,iInput++ ,iInput);
>
> }
>
> My result is
>
> * * *A[2]B[3]C[0]D[3]
>
> i could not find why is it so.
>
> please explain.
>
> using of printf should be ignored you can use cout.


i got the answer thanx
http://www2.research.att.com/~bs/bs_...aluation-order
Reply With Quote
  #3 (permalink)  
Old 11-26-2009, 09:54 AM
Fred Zwarts
Guest
 
Posts: n/a
Default Re: cant get the concept of this result

dost <kapilkaushik.mca@gmail.com> typed
(in 9b86e9f7-9a37-415c-bc96-49efce1a84dc...oglegroups.com)
> Guess the result and then write in ur editor
>
> void DisplayInterestingRsult2(int a, int b)
> {
>
> printf("\n\tA[%d],B[%d]\n",a,b);
> }
>
>
> int _tmain(int argc, _TCHAR* argv[])
> {
>
> int iInput = 0;
> printf("\ni = 0 FUN(i++,++i,i++,i)\n");
> DisplayInterestingRsult(iInput++,++iInput,iInput++ ,iInput);
> }
>
>
>
>
> My result is
>
> A[2]B[3]C[0]D[3]
>
> i could not find why is it so.
>
> please explain.
>
> using of printf should be ignored you can use cout.


I wonder whether you tried to compile and link this code.
There are a lot of problems in it.
The function DisplayInterestingRsult is not defined.
Maybe you meant DisplayInterestingRsult2, but that has a different number of parameters.
There is no function main, so it will not link to a main program. So, it will not run.
Assuming you fixed the above problems, I wonder why your
printf("\ni = 0 FUN(i++,++i,i++,i)\n");
does not not show up in your result, but anything is possible, because the main problem is
undefined behaviour, because the order of evaluation of the parameter of DisplayInterestingRsult
is not defined.

Reply With Quote
  #4 (permalink)  
Old 11-26-2009, 10:14 AM
dost
Guest
 
Posts: n/a
Default Re: cant get the concept of this result

On Nov 26, 3:54*pm, "Fred Zwarts" <F.Zwa...@KVI.nl> wrote:
> dost <kapilkaushik....@gmail.com> typed
> (in 9b86e9f7-9a37-415c-bc96-49efce1a8...@b25g2000prb.googlegroups.com)
>
>
>
> > Guess the result and then write in ur editor

>
> > void DisplayInterestingRsult2(int a, int b)
> > {

>
> > printf("\n\tA[%d],B[%d]\n",a,b);
> > }

>
> > int _tmain(int argc, _TCHAR* argv[])
> > {

>
> > int iInput = 0;
> > printf("\ni = 0 FUN(i++,++i,i++,i)\n");
> > DisplayInterestingRsult(iInput++,++iInput,iInput++ ,iInput);
> > }

>
> > My result is

>
> > * * A[2]B[3]C[0]D[3]

>
> > i could not find why is it so.

>
> > please explain.

>
> > using of printf should be ignored you can use cout.

>
> I wonder whether you tried to compile and link this code.
> There are a lot of problems in it.
> The function DisplayInterestingRsult is not defined.
> Maybe you meant DisplayInterestingRsult2, but that has a different numberof parameters.
> There is no function main, so it will not link to a main program. So, it will not run.
> Assuming you fixed the above problems, I wonder why your
> printf("\ni = 0 FUN(i++,++i,i++,i)\n");
> does not not show up in your result, but anything is possible, because the main problem is
> undefined behaviour, because the order of evaluation of the parameter of DisplayInterestingRsult
> is not defined.


i am sorry for my mistake.
i just copied different function.

void DisplayInterestingRsult(int a, int b, int c, int d)
{

printf("\n\tA[%d],B[%d],C[%d],D[%d]\n",a,b,c,d);
}

int _tmain(int argc, _TCHAR* argv[])
{

int iInput = 0;
printf("\ni = 0 FUN(i++,++i,i++,i)\n");
DisplayInterestingRsult(iInput++,++iInput,iInput++ ,iInput);

}

sorry everybody.

Reply With Quote
  #5 (permalink)  
Old 11-26-2009, 05:33 PM
red floyd
Guest
 
Posts: n/a
Default Re: cant get the concept of this result

dost wrote:
> Guess the result and then write in ur editor
>
> void DisplayInterestingRsult2(int a, int b)
> {
>
> printf("\n\tA[%d],B[%d]\n",a,b);
> }
>
>
> int _tmain(int argc, _TCHAR* argv[])
> {
>
> int iInput = 0;
> printf("\ni = 0 FUN(i++,++i,i++,i)\n");
> DisplayInterestingRsult(iInput++,++iInput,iInput++ ,iInput);
> }
>
>
>
>
> My result is
>
> A[2]B[3]C[0]D[3]
>
> i could not find why is it so.
>
> please explain.
>
> using of printf should be ignored you can use cout.


The result is undefined. The call to DisplayInterestingResult results
in undefined behavior -- the value of iInput is modified multiple times
without an intervening sequence point.

Therefore *ANY* answer you get can be considered "correct".
Reply With Quote
  #6 (permalink)  
Old 11-28-2009, 02:57 AM
Daniel Pitts
Guest
 
Posts: n/a
Default Re: cant get the concept of this result

Fred Zwarts wrote:
>
> I wonder whether you tried to compile and link this code.
> There are a lot of problems in it.
> The function DisplayInterestingRsult is not defined.
> Maybe you meant DisplayInterestingRsult2, but that has a different number of parameters.
> There is no function main, so it will not link to a main program. So, it will not run.
> Assuming you fixed the above problems, I wonder why your
> printf("\ni = 0 FUN(i++,++i,i++,i)\n");
> does not not show up in your result, but anything is possible, because the main problem is
> undefined behaviour, because the order of evaluation of the parameter of DisplayInterestingRsult
> is not defined.
>


Also, what is _tmain, and where is the #include <cstdio>?
Reply With Quote
 
Reply

Popular Tags in the Forum
concept, result

Thread Tools
Display Modes

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 Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hanging XMLRPC calls Rickard Sjostrom Newsgroup comp.lang.ruby 1 09-29-2009 06:53 AM
A container library in C: Part 3. List container implementation jacob navia Newsgroup comp.lang.c 5 09-28-2009 08:19 PM
Re: Matching and reordering substrings Muthia Kachirayan Newsgroup comp.soft-sys.sas 0 12-04-2008 10:51 AM
How to populate the same result for 2 visits ? Learner Newsgroup comp.soft-sys.sas 2 11-13-2008 01:06 PM
Re: why DOWNAME format gave wrong result??? juanwu36@hotmail.com Newsgroup comp.soft-sys.sas 0 01-17-2005 06:37 PM



All times are GMT. The time now is 04:27 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.