Fill This Form To Receive Instant Help

Help in Homework
Facebook Reviews
Quora Reviews
Google UK Reviews


Homework answers / question archive / Hand-written exercises

Hand-written exercises

Computer Science

Hand-written exercises. Do these alone first, then (if possible) get together with two or three other people to check each other's answers. Agree among yourselves what the answers are BEFORE you write little test programs to verify the answers. Turn in the PDF of one paper solution, with all team members' names on it. I do not want the test programs, just the team's paper solution. I suggest using truth tables to analyze many of these. Some of these are tricky!


Write a simple expression that is equivalent to !(!a && !b ) without using !


Write a simple expression that is equivalent to !(!a || !b ) without using !


If you are rich then you are automatically happy. If you are not rich then you may still be happy but only if you are both employed and healthy. Complete the following assignment statement using rich, employed and healthy (all bool variables) along with one or more logical operators.


happy =  


Which of the following are not equivalent to!(cold && rainy)? Hint: test your answers with a truth table.
!(cold && rainy) || !rainy
!cold || !rainy  
(!rainy || !cold) && (!cold || !rainy)
!!(!rainy || !cold)
!cold && !rainy


Simplify (big && red) || red  


Simplify (big || red) && big  


Simplify !(big || red) && big   


Assume that a, b and c are variables of type bool. Which of the following are not correct logical expressions in C++ (meaning they will not compile)?
(!(a) && (!b))
!(!a || !!b)
a ! && b && b
!!a && !!b || !!c
(!(!(!(!a))) && !b)


Simplify the following if-else statement by using logical operators. You will only need one if-else. Assume that a and b are variables of type bool.


if (a) 
if (b)
cout << "Fred";
else
cout << "Derf";
else
cout << "Derf";


Simplify the following if-else statement by using logical operators. You will only need one if-else.


if (a)
cout << "Man";
else if (b)
cout << "Man";
else 
cout << "Van";


Specify the ranges of values of n (of type int) for which the following statement prints "Hello", "Goodbye" or nothing.


if (n < 10)
if (n > 5)
cout << "Hello";
else 
cout <<"Goodbye";

Write the following if-else statement without using a "!" in the test condition:


if (!narcissist && !psychopath)
cout << "friend material";
else
cout << "run away!";


Simplify the following nested if-else statement into a single if-else. Do not use a "!" in your answer.


if (!famous)
if (!rich)
cout << "Unhappy";
else 
cout << "Happy";
else
cout << "Happy";


For each of the following pairs of expressions determine if they are "equivalent" or "not equivalent". Equivalent means they will produce the same columns of T/F values in truth tables. Test your answer by plugging in sample values. Careful: some of these are tricky.


a <= b 
a < b && a == b


a <= b || b <= c
a <= c


(p || q) && r
  (p && r) || (q && r)


 a == b
  !(a > b || b > a)


!(p && q)
  !p || !q


p && (q || !p)
p && q


!(!p && q)
!q || p


q || p || !q
p || !p


!(big || round)
!big || !round


(big && round) || (big && !round)
big

-

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions