Value of x After Logic & Math Task w/ x=2

  • Context: MHB 
  • Thread starter Thread starter vb14
  • Start date Start date
  • Tags Tags
    Logic
Click For Summary

Discussion Overview

The discussion revolves around determining the value of x after a series of conditional statements in a programming context, starting with x=2. The focus is on logic and mathematical reasoning as applied in programming constructs.

Discussion Character

  • Homework-related
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant presents a task involving conditional statements and asks for the value of x after each statement is evaluated.
  • Several participants question the truth value of the conditions in each statement, specifically whether they evaluate to true or false.
  • Another participant asserts that all conditions are false, suggesting that none of the THEN parts will execute.
  • A later reply challenges the assessment of the second condition, stating that the first part of the OR is true, which would make the entire OR true.
  • Some participants conclude that the final value of x is 3, indicating that at least one condition must have evaluated to true.

Areas of Agreement / Disagreement

There is disagreement regarding the truth values of the conditions in the statements. Some participants assert that all conditions are false, while others argue that the second condition should evaluate to true, leading to different conclusions about the final value of x.

Contextual Notes

The discussion does not resolve the truth values of the conditions definitively, and there are assumptions about the interpretation of logical operators that remain unaddressed.

vb14
Messages
8
Reaction score
0
Hi Folks,
I am stack with following task:What is the value of x after each of these statements is encountered in a
computer program if x=2 before the statement is reached?

(i) if (6+2=9) then x:=x+1 .
(ii) if ((3+2=5) OR (2+3=3))then x:=x+1 .
(iii) if ((12+4=17) AND (4+5=9)) then x:=x+1.

Note 1 OR is ∨ AND is ^
Note 2 := is an assignment sign.Any help will be appreciated.
Thanks.
 
Physics news on Phys.org
Is the IF part of i) true?
Is the IF part of ii) true?
Is the IF part of iii) true?
 
Ackbach said:
Is the IF part of i) true?
Is the IF part of ii) true?
Is the IF part of iii) true?

(i) false
(ii) false
(III) false
 
vb14 said:
(i) false
(ii) false
(III) false

(ii) is incorrect. The first part of the OR is true, making the entire OR true. So, which THEN parts will execute?
 
tell me please the answer is 3:)
 
vb14 said:
tell me please the answer is 3:)

Correct!
 
Thanks a lot, I feel like a genius now!:D
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 17 ·
Replies
17
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 40 ·
2
Replies
40
Views
8K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
2
Views
4K