yups...it is compiler dependent...but a logic is necessary to get it...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
Hai i tried the same in TC compiler. i got the output as 17. I guess the
output should be 17 as explained by Prateek Jain
On 30 May 2012 02:26, rahul ranjan rahul.ranjan...@gmail.com wrote:
it first calculates from right to left and then performs addition
so after a++ its still 4(with
okk
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
Hey answer will be 18 as follows. First ++a(5)+ ++a(6) + a++(6)=17 + one
post increment= 18.
On Thu, May 31, 2012 at 3:13 AM, Prateek Jain prateek10011...@gmail.comwrote:
okk
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to
#includestdio.h
int main()
{
int a=4;
printf(%d\n,++a + ++a + a++);
return 0;
}
according to me output should be 17, but it is coming out to be 18.
plz explain it??
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
At first the value of a is calculated for the statement, that is 6, and
then statement is evaluated with a=6
so it is 6 + 6 + 6 = 18
and as you know after that the value of a becomes 7 for the rest of the
program.
On Mon, May 28, 2012 at 10:02 AM, ashish pant asheesh...@gmail.com wrote:
how is it 6?
++a(5) + ++a(6) + a++(6) it shud be 17
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
I implemented ++ for a simple class and got 17.
class A
{
public :
int val;
A(int v):val(v){}
int operator++()
{
cout empty arg called\n;
return ++val;
}
int operator++(int x)
{
cout x:arged arg called\n;
return val++;
}
};
--
A b(4);
cout ++a + ++a +a++endl;
17
but
it first calculates from right to left and then performs addition
so after a++ its still 4(with a promise to increment in next
statement). then ++a makes it 5. then further ++a makes it 6
now the addition phase comes into play value of a is 6 now so total
18 if it
@all : no need to argue on this ...output is compiler dependent ... it
violates sequence point rule :) :).
On Wed, May 30, 2012 at 2:26 AM, rahul ranjan rahul.ranjan...@gmail.comwrote:
it first calculates from right to left and then performs addition
so after a++ its still 4(with a
10 matches
Mail list logo