Ask your own question, for FREE!
Mathematics 20 Online
OpenStudy (lgbasallote):

Given a variable x, initially x = 0, find the value of x after the statement: if 6 + 6 = 12 then x := x + 1. Note: ":=" means assignment

OpenStudy (anonymous):

Isnt it 1

OpenStudy (lgbasallote):

why?

OpenStudy (anonymous):

Since 6+6=12 is a TRUE statement x=0+1=1

OpenStudy (lgbasallote):

?

OpenStudy (anonymous):

If 6+6=12 then x=x+1 ^ THIS STATEMENT IS TRUE so, x=0+1

OpenStudy (lgbasallote):

why x = 0 + 1?

OpenStudy (anonymous):

because the initial value of x is 0

OpenStudy (lgbasallote):

so it's just substitution?

OpenStudy (anonymous):

Yes.......... x will be initial value of x +1

OpenStudy (lgbasallote):

then what's the purpose of 6 + 6 = 12?

OpenStudy (anonymous):

Its the given condition........ we do x=x+1 only if the given condition is TRUE

OpenStudy (lgbasallote):

what if it's false?

OpenStudy (anonymous):

The value of x will not increase by 1

OpenStudy (anonymous):

That means we wont do x=x+1

OpenStudy (lgbasallote):

so what will be done?

OpenStudy (anonymous):

nothing as nothing said to be done if the condition is FALSE

hartnn (hartnn):

like x will not be incremented, it will remain 0. u learning programming?

OpenStudy (lgbasallote):

couldn't x be any value because according to conditional statement.. if p is false then p->q is true for any truth value of q

OpenStudy (lgbasallote):

isn't this related to conditional statements?

OpenStudy (lgbasallote):

and @hartnn since it's in the math section...this is just discrete mathematics

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!