Then you broke laserlight's code. If you run it, exactly as written, you will actually get 1000.
Then you broke laserlight's code. If you run it, exactly as written, you will actually get 1000.
I get 1000 when I run the program whose source code I showed. If you get the leading zeroes, it implies that you are not running my most recent example.Originally Posted by transgalactic2
More importantly, you need to understand what the code commented by "Find the first non-zero." and "Print the significant digits." does.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
i fixed it
why when i put
Code:int digits[50]={9, 1, 100}; it gives me 10019 ??
i changed your code to
Code:/* Find the first non-zero. */ for (i = NUM_DIGITS - 1; i > 0 && digits[i] == 0; --i); temp4=i; /* Print the significant digits. */ for (i=49; i >= 0; --i) { if (temp4>=i){ printf("%d", digits[i]); } } putchar('\n');
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
i expect
900 +10 +100
1010
??
Since the first 9 means 9 and not 900 that seems like a rather silly expectation.
This is frustrating. It looks like you cannot decide how you really want to interpret the array.Originally Posted by transgalactic2
At this point I would like to ask what exactly are you trying to do. What is the point of this whole exercise?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
10^2 10^1 10^0 etc..
That is too vague.Originally Posted by transgalactic2
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)