6÷2(1+2)= ?
Is the answer 1 or 9 ?
			
			
									
									6÷2(1+2)= ?
6÷2(1+2)= ?
C provides the infinitely-abusable goto statement, and labels to branch to. Formally, the goto is never necessary, and in practice it is almost always easy to write code without it. We have not used goto in this book. -- K&R (2nd Ed.) : Page 65
						Re: 6÷2(1+2)= ?
I'd say 9, using left to right order of operations...
http://www.google.com/search?cx=c&sourc ... B72(1%2B2)
			
			
									
									http://www.google.com/search?cx=c&sourc ... B72(1%2B2)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
						Re: 6÷2(1+2)= ?
The term is mathematically:
6 / 2 * 3 = 6 * 2^(-1) * 3 = 9
because the sign "/" is nothing else then the inverse of the following number and multiplication is associativ.
Further there is still a "*" between 2 and 3, otherwise you have to use brackets. If there should be no "*" and no brackets, its just undefined.
			
			
									
									6 / 2 * 3 = 6 * 2^(-1) * 3 = 9
because the sign "/" is nothing else then the inverse of the following number and multiplication is associativ.
Further there is still a "*" between 2 and 3, otherwise you have to use brackets. If there should be no "*" and no brackets, its just undefined.
pb 5.11
						Re: 6÷2(1+2)= ?
6÷2(1+2) =
6 / 2 * ( 1 + 2 ) =
6 / 2 * ( 3 ) =
6 / 2 * 3 =
3 * 3 =
9
Why:
- there's no operator between 2 and (1+2) so it's a multiplication
- first get the value of anything between the brackets
- substitute brackets + expression within with result
- do the rest
			
			
													6 / 2 * ( 1 + 2 ) =
6 / 2 * ( 3 ) =
6 / 2 * 3 =
3 * 3 =
9
Why:
- there's no operator between 2 and (1+2) so it's a multiplication
- first get the value of anything between the brackets
- substitute brackets + expression within with result
- do the rest
					Last edited by blueznl on Thu Aug 25, 2011 5:07 pm, edited 2 times in total.
									
			
									( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
						( The path to enlightenment and the PureBasic Survival Guide right here... )
Re: 6÷2(1+2)= ?
my calculator said 1.
I believe that it prioritize the use of the parenthesis like a higher priority then if it was written like : 6 / 2 * 3
And I would have said 1 too, since the "2" is near the parenthesis without operator : it is implicit.
(as you can easily guess the calculator I use is a casio Graph100+ , that is if you want too test it)
 , that is if you want too test it)
			
			
									
									I believe that it prioritize the use of the parenthesis like a higher priority then if it was written like : 6 / 2 * 3
And I would have said 1 too, since the "2" is near the parenthesis without operator : it is implicit.
(as you can easily guess the calculator I use is a casio Graph100+
 , that is if you want too test it)
 , that is if you want too test it)_________________________________________________
My Website : CeriseCode (Warning : perpetual changes & not completed )
)
						My Website : CeriseCode (Warning : perpetual changes & not completed
 )
)Re: 6÷2(1+2)= ?
Thats the problem. There are common standards which should be used. And one of them is, that you can omit a dot (for mutliplication) but never ever a paranthesis if it is not absolutly obvious how the term should be calculated.graph100 wrote:And I would have said 1 too, since the "2" is near the parenthesis without operator : it is implicit.
Calculators (including mine) seem to bind a term in the way you observated it. However thats just arbitrariness. In a term like this you should use paranthesis right or avoid the division operator.
pb 5.11
						Re: 6÷2(1+2)= ?
The order of precedence is denoted by the mnemonic BODMAS.
Brackets (parenthesis)
Orders (powers/roots)
Divide/Multiply
Add/Subtract
Where operators have equal precedence, overiding precedence is given to the left most operator.
So the calculation order is:-
1) 6 ÷ 2 ( 1 + 2 )
2) Brackets - gives 6 ÷ 2 x 3
3) Divide is leftmost - gives 3 x 3
4) Implicit multiply gives 3 x 3 = 9
So the answer is 9, as blueznl states.
			
			
									
									
						Brackets (parenthesis)
Orders (powers/roots)
Divide/Multiply
Add/Subtract
Where operators have equal precedence, overiding precedence is given to the left most operator.
So the calculation order is:-
1) 6 ÷ 2 ( 1 + 2 )
2) Brackets - gives 6 ÷ 2 x 3
3) Divide is leftmost - gives 3 x 3
4) Implicit multiply gives 3 x 3 = 9
So the answer is 9, as blueznl states.
Re: 6÷2(1+2)= ?
 This was the topic of a big debate between some classmates recently (not the exact same numbers, of course), and the conclusion was:
 This was the topic of a big debate between some classmates recently (not the exact same numbers, of course), and the conclusion was:Without explicit parentheses, the division should occur first (left-to-right, resulting in 9 in this case). It is misleading to write the division sign and not the implied multiplication sign. Furthermore, division should have equal priority to multiplication since it is really multiplication by the inverse (as gnasen said).
Some calculators may multiply the 2 before dividing (for convenience?) but really that is non-standard.
Re: 6÷2(1+2)= ?
the moral is : when you take exam, type all the operator to obtain a sure answer 
			
			
									
									
_________________________________________________
My Website : CeriseCode (Warning : perpetual changes & not completed )
)
						My Website : CeriseCode (Warning : perpetual changes & not completed
 )
)







