StudySmarter AI is coming soon!

- :00Days
- :00Hours
- :00Mins
- 00Seconds

A new era for learning is coming soonSign up for free

Suggested languages for you:

Americas

Europe

Q42E

Expert-verifiedFound in: Page 16

Book edition
7th

Author(s)
Kenneth H. Rosen

Pages
808 pages

ISBN
9780073383095

**What is the value of x after each of these statements is encountered in a computer program, if x = 1 before the statement is reached? **

**a) if ${\mathbf{x}}{\mathbf{+}}{\mathbf{2}}{\mathbf{=}}{\mathbf{3}}$ then ${\mathbf{x}}{\mathbf{=}}{\mathbf{x}}{\mathbf{+}}{\mathbf{1}}$ b) if ${\mathbf{(}}{\mathbf{x}}{\mathbf{+}}{\mathbf{1}}{\mathbf{=}}{\mathbf{3}}{\mathbf{)}}$OR ${\mathbf{(}}{\mathbf{2}}{\mathbf{x}}{\mathbf{+}}{\mathbf{2}}{\mathbf{=}}{\mathbf{3}}{\mathbf{)}}$ then ${\mathbf{x}}{\mathbf{=}}{\mathbf{x}}{\mathbf{+}}{\mathbf{1}}$ c) if ${\mathbf{(}}{\mathbf{2}}{\mathbf{x}}{\mathbf{+}}{\mathbf{3}}{\mathbf{=}}{\mathbf{5}}{\mathbf{)}}$AND ${\mathbf{(}}{\mathbf{3}}{\mathbf{x}}{\mathbf{+}}{\mathbf{4}}{\mathbf{=}}{\mathbf{7}}{\mathbf{)}}$ then ${\mathbf{x}}{\mathbf{=}}{\mathbf{x}}{\mathbf{+}}{\mathbf{1}}$ d) if ${\mathbf{(}}{\mathbf{x}}{\mathbf{+}}{\mathbf{1}}{\mathbf{=}}{\mathbf{2}}{\mathbf{)}}$ XOR ${\mathbf{(}}{\mathbf{x}}{\mathbf{+}}{\mathbf{2}}{\mathbf{=}}{\mathbf{3}}{\mathbf{)}}$ then ${\mathbf{x}}{\mathbf{=}}{\mathbf{x}}{\mathbf{+}}{\mathbf{1}}$e) if x < 2 then${\mathbf{x}}{\mathbf{=}}{\mathbf{x}}{\mathbf{+}}{\mathbf{1}}$**

a) x = 2

b) x = 1

c) x = 2

d) x = 1

e) x = 2

Mathematical statement is a sentence that is either true or false.

We write given expression as,

** **

**$x+2=3$**

Given** **that initially *x* = 1,

Therefore, substitute 1 for *x* in the below given equation,

x = x+1

= 1+1.

=2

Hence, x = 2.

We write given expression,

Given that x = 1**,**

$\mathrm{x}+1=1+1\phantom{\rule{0ex}{0ex}}\ne 3$

$2\mathrm{x}+2=2+2\phantom{\rule{0ex}{0ex}}\ne 3$

False or false gives false.

Hence, x = 1

We write given expression as,

Given that x = 1,

$2x+3=2+3\phantom{\rule{0ex}{0ex}}=5$

$3x+4=3+4\phantom{\rule{0ex}{0ex}}=7$

True and true gives true.

Hence, x = 2.

We write given expression,

Given that x = 1,

$\mathrm{x}+1=2$

$\mathrm{x}+2=3$

True Ex-Or True gives false.

Hence, x = 1

We write given expression,

Given that x = 1,

Here 1 < 2

Hence,** **x = 2**.**

94% of StudySmarter users get better grades.

Sign up for free