Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Given two Boolean variables a and b , are the following expressions equivalen

ID: 3764287 • Letter: 3

Question

3. Given two Boolean variables a and b, are the following expressions equivalent?

     !( !a )

     a

44. Write a program that calculates the are of the following figures: (

Calculated the area of a square(5 points)

0

Calculated the area of a rectangle (5 points)

0

Printed results correctly (5 points)

0

Discussed why the two are not equal in area(5 points)

0

Why are they equal or not equal?)

      a square of side 0.666666667

      a rectangle of side 1/9 and 4

Calculated the area of a square(5 points)

0

Calculated the area of a rectangle (5 points)

0

Printed results correctly (5 points)

0

Discussed why the two are not equal in area(5 points)

0

Why are they equal or not equal?)

Explanation / Answer

Answer 3:

Yes they are equivalent

Let b = !a

then draw truth table

hence you can see that !b = a i.e. !(!a) = a

Answer 44

#include <stdio.h>

int main()
{
   float square_side;
   float rec_a,rec_b;

   square_side = 0.666666667;
   rec_a = 1.0/9;
   rec_b = 4;
   float Area_square = square_side*square_side;
   float Area_rectangle = rec_a*rec_b;
   printf("Area of aquare %lf ", Area_square);
   printf("Area of rectangle %lf ", Area_rectangle);
   if( Area_square == Area_rectangle )
       printf("The areas are same ");
   else
       printf("The areas are different ");
}

They are different because floating point numbers are stored in IEEE 32 bit format which has a base part and exponent part. When you multiply two floating point numbers then accuracy gets lost. Floating point numbers are accrate upto 7 decimal places. The areas are coming different because they might have different exponent part in their respective IEEE 32 bit representation.

For more about IEEE format read this

https://en.wikipedia.org/wiki/Single-precision_floating-point_format

a b !b 0 1 0 1 0 1
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote