Look at the place where you calculate the sum and product. Is that inside the loop? What values are number1 and number2. Do these change at the time of calculation?

Printable View

- 08-22-2013, 03:31 PMSurfManRe: Two conditions in a while statement
- 08-22-2013, 03:55 PMloki88Re: Two conditions in a while statement
Oh, I thought if I did

Code:`int sum = number1 + number2;`

If I put the same line of code in the loop the value gets printed right. Thanks for pointing out the error. - 08-22-2013, 04:03 PMSurfManRe: Two conditions in a while statement
When you type

Code:`int sum = number1 + number2;`

- 08-22-2013, 04:05 PMgimbal2Re: Two conditions in a while statement
I can't speak for the rest of the world, but speaking out of experience in the NL: math schooling nowadays sucks balls and is being phased out more and more. Only in the very beginning of my education did (basic) math really matter; even I, still quite young but not in my twenties anymore, have never been properly trained to

**apply**math in the real world; I was only taught how to do some calculations which I quickly forgot again because I really don't need that on a daily basis.

The only math that really stuck with me was self-taught; for game-development purposes. Because at least that is math I have learned to apply. - 08-22-2013, 04:14 PMloki88Re: Two conditions in a while statement
I follow gimbal2. I live in Belgium, very close to the Netherlands.

I had basic math in highschool. After that, I got an university degree in criminology. I only needed statistics.

Don't ask me anything on the math I have seen in high school. I simply didn't use it for years and I forgot everything. - 08-22-2013, 04:27 PMJosAHRe: Two conditions in a while statement
So far for the 'knowledge economy' in Belgium and the Netherlands. All 'hard' sciences are based on at least a bit of math and imho computer science is no exception. In this forum (and others) problems are 'solved' where a bit of math could've given a smarter, shorter, faster solution, but indeed, math is not en vogue anymore ...

kind regards,

Jos - 08-22-2013, 05:19 PMjim829Re: Two conditions in a while statement
Or just use the appropriate quadratic formula algorithm. Thought of that but I figured the OP wanted to play around with loops and random numbers.

Regards,

Jim - 08-22-2013, 05:23 PMjim829Re: Two conditions in a while statement
- 08-22-2013, 06:08 PMJosAHRe: Two conditions in a while statement
- 08-22-2013, 06:21 PMKevinWorkmanRe: Two conditions in a while statement
- 08-22-2013, 06:26 PMjim829Re: Two conditions in a while statement
I guess I didn't explain myself clearly. By appropriate I meant appropriate for floating point calculations.

Quadratic equation - Wikipedia, the free encyclopedia

Regards,

Jim

- 08-22-2013, 06:37 PMJosAHRe: Two conditions in a while statement