Anyone can tell me the different between this.....in programming c ?
Anyone can tell me the different between this.....in programming c ?
Test it.
Gives...Code:#include <stdio.h> #include <stdlib.h> int main(void) { int i; int r; // test #1 i = 7; r = ++i * 10; printf("%d %d \n",i,r); // test #2 i = 7; r = i++ * 10; printf("%d %d \n",i,r); return 0; }
8 80
8 70
Why two different answers?
++i increments i before the calculation
i++ increments i after the calculation
And, you wouldn't believe how many times I've tripped over this in various programs.
Last edited by CommonTater; 09-23-2010 at 11:44 PM.
The expression is malformed, having more right parenthesis, than left.
As for solving it - what fun would that be? Write a little program to solve it.
Big silly you! This forum is for programming, not math!
i dont want in CODING .... if anyone can solve it in math and tell what it answer?
i know but i want to make sure the answer same with other people answer...can anyone answer this:
n=2
n*=((3*4)/2)-9);
in math
Instead of reducing members of this community into pocket calculators, you could actually use a pocket calculator to double check. That said, this is the kind of thing that proves that you are not smarter than a fifth grader if you cannot compute it mentally.Originally Posted by hakimstm1b
That is correct. But are you sure that I am telling the truth? Really, what is stopping you from using a pocket calculator, or even just taking a pen and paper and working it out step by step? If you cannot trust yourself on something so simple when you work it out meticulously, you're doomed.Originally Posted by hakimstm1b
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)