Welcome!
Log In
Create A New Profile
Home
>
2010
>
ICT2613
> Topic
Advanced
Precedence rules
Posted by
HTC
Announcements
Last Post
SoC Curricula
09/30/2017 01:08PM
Demarcation or scoping of examinations and assessment
02/13/2017 07:59AM
School of Computing Short Learning Programmes
11/24/2014 08:37AM
Unisa contact information
07/28/2011 01:28PM
Forums
Messages
New
HTC
Precedence rules
October 11, 2010 10:02PM
Registered: 14 years ago
Posts: 16
Rating: 0
Assignment 1 question 7 refers.
How does the lecturer get 6?
please advise
Reply
Quote
Mac
Re: Precedence rules
October 12, 2010 06:56AM
Admin
Registered: 18 years ago
Posts: 10,001
Rating: 353
This is straight from the solution?
What is the result of the following expression using the precedence rules in Java?
4-2*3/6%2
1. 1
2. 4
3. 3
4. -1
Solution: 3
Reply
Quote
HTC
Re: Precedence rules
October 14, 2010 02:37PM
Registered: 14 years ago
Posts: 16
Rating: 0
Hi Doc,
I don`t get it
.. working from left to right the equation becomes
4-(((2*3)/6)%2)
4-((6/6)%2)
4-(1%2)
? 1%2 is 0.5?
4-.5
=3.5?
from assignment1 question 7
6-2*(5+2)%2
6-((2*7)%2)
6-0
6
is my reasoning in line with JAVA lingo?
Reply
Quote
Mac
Re: Precedence rules
October 15, 2010 07:36AM
Admin
Registered: 18 years ago
Posts: 10,001
Rating: 353
4-(1%2)
Think in terms of long division as you did in school
2 goes into 1 how many times? 0 times. What remains? 1.
Thus it is 4-1 = 3
Reply
Quote
Newer Topic
Older Topic
Print View
RSS
Sorry, only registered users may post in this forum.
Click here to login