Programming and discrete maths problem

Watch
Announcements
Thread starter 5 years ago
#1
Consider these lines of code from a C program:
if (!(x!=0 && y/x < 1)|| x==0)

printf (“True”);

else

printf (“False”);

a. Express the code in this statement as a compound statement using the logical connectives and these predicates

E(x): x = 0

L(x,y): y/x < 1

A(z): “z is assigned to printf”

where x and y are integers and z is a Boolean variable (with values True and False)

b. Use the laws of propositional logic to simplify the statement by expressing it in a simpler form.

c. Translate the answer in part (b) back into C codes.

How can it be solved in easiest way?
0
5 years ago
#2
Well the first thng to do is use de morgan's law on the statement.
1
X

new posts
Back
to top
Latest
My Feed

Oops, nobody has postedin the last few hours.

Why not re-start the conversation?

see more

See more of what you like onThe Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Poll

Join the discussion

Have you experienced financial difficulties as a student due to Covid-19?

Yes, I have really struggled financially (56)
17.39%
I have experienced some financial difficulties (91)
28.26%
I haven't experienced any financial difficulties and things have stayed the same (120)
37.27%
I have had better financial opportunities as a result of the pandemic (44)
13.66%
I've had another experience (let us know in the thread!) (11)
3.42%