I am a novice programmer and need help.....
#include <stdio.h>
int main (void)
}
int n1=2;
int n2=0;
n2= (++n1) + (++n1);
printf("Result= %d",n2);
return 0;
}
Result= 8 How is this possible??
Similarly,
#include <stdio.h>
int main (void)
}
int n1=2;
int n2=0;
n2= (++n1) + (++n1) + (++n1);
printf"Result= %d",n2);
return 0;
}
Result= 13 How is it possible??
All the results does not match up with my understanding of C. Please, I need help.
Thank you.
p.user01 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
Utsav Chokshi 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
p.user01 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
p.user01 0 Newbie Poster
p.user01 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
chrjs 42 Junior Poster in Training
Narue 5,707 Bad Cop Team Colleague
p.user01 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
sbesch 2 Newbie Poster
p.user01 0 Newbie Poster
Narue 5,707 Bad Cop Team Colleague
tomato.pgn -6 Posting Whiz in Training
tomato.pgn -6 Posting Whiz in Training
Narue 5,707 Bad Cop Team Colleague
CoilFyzx 0 Newbie Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
tomato.pgn -6 Posting Whiz in Training
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
Killer.bee commented: Ohh i think you need to rereas -1
Nick Evan commented: counter. +16
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
tomato.pgn -6 Posting Whiz in Training
Fbody commented: Nice, arguing about pre- vs. post- and both examples are pre- -3
Narue 5,707 Bad Cop Team Colleague
Killer.bee commented: Explain it with explanation where it gave arbitrary result to proof your words -1
jonsca commented: Unwarranted and undeserved +14
tomato.pgn -6 Posting Whiz in Training
Narue 5,707 Bad Cop Team Colleague
p.user01 0 Newbie Poster
tomato.pgn -6 Posting Whiz in Training
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.