i found this problem in c/c++
when i wrote this code
int a=5,b;
b=++a +(+=a + a--);
it gave the output of b as 21
and when i wrote
int a;
int b=++a + (++a + a--);
it gave b as 18
why the answers are varying for the same compiler(turbo c++)?
also when i tried this code in gcc compiler
the output was 20...
topsyturby 0 Newbie Poster
Tom Gunn 1,164 Practically a Master Poster
topsyturby 0 Newbie Poster
Tom Gunn 1,164 Practically a Master Poster
topsyturby 0 Newbie Poster
Tom Gunn 1,164 Practically a Master Poster
topsyturby 0 Newbie Poster
Tom Gunn 1,164 Practically a Master Poster
topsyturby 0 Newbie Poster
Tom Gunn 1,164 Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.