Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Question

  • 14-05-2006 11:55pm
    #1
    Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭


    okay supposidly (spelling) we have meant to have covered this topic in my maths class (dispite not one person remembering doing it)

    anyways this question appeared on an exam and i hadn't a clue how to do it.

    i tried researching it in books and on the net but can't find anything on it's topic, probably would help if i knew what the particular type of maths was called.

    so here's the Q.

    What is the value of x after each of these statements is encounterd in a computer program, if x = 2 before the statement is reached.

    (i) if (7 + 2 = 8) then x := x + 1

    (ii) if ((2 + 4 = 7) OR (2 + 3 = 3)) then x := x + 1

    (iii) if ((2 + 4 = 7) AND (4 + 5 = 9)) then x := x + 1


    does anyone know what i should be doing?

    Thanks for your help in advance.


Comments

  • Registered Users, Registered Users 2 Posts: 16,201 ✭✭✭✭Pherekydes


    (i) if (7 + 2 = 8) then x := x + 1

    If the statement in the bracket is true, then increment x.

    (ii) if ((2 + 4 = 7) OR (2 + 3 = 3)) then x := x + 1

    If either of the statements in the brackets are true then increment x.

    (iii) if ((2 + 4 = 7) AND (4 + 5 = 9)) then x := x + 1

    If both of the statements in the brackets are true, then increment x.


    Answers: (i) The statement is not true, x=2 (i.e. x is not incremented)

    (ii) Neither of the statements are true, x=2

    (iii) Both of the statements are not true (one is, one isn't), x=2


  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    cheers that what i thought it was but just wanted to make sure, thanks for the reply.


  • Registered Users, Registered Users 2 Posts: 527 ✭✭✭Sean^DCT4


    Slow coach wrote:
    (i) if (7 + 2 = 8) then x := x + 1

    If the statement in the bracket is true, then increment x.

    (ii) if ((2 + 4 = 7) OR (2 + 3 = 3)) then x := x + 1

    If either of the statements in the brackets are true then increment x.

    (iii) if ((2 + 4 = 7) AND (4 + 5 = 9)) then x := x + 1

    If both of the statements in the brackets are true, then increment x.


    Answers: (i) The statement is not true, x=2 (i.e. x is not incremented)

    (ii) Neither of the statements are true, x=2

    (iii) Both of the statements are not true (one is, one isn't), x=2
    It's very simple computer program notation.. But is this not some form of Math Logic, i.e. Propositional / Predicate logic ?

    Should the answer not be shown as True/False/Imply... Following the Truth-tables?
    i. F -> F
    ii. F V F -> F (V=or)
    iii. F & T -> cant remember off the top of my head but is probably F


Advertisement