hw3_solution - EME5 Homework 3 Solutions 3 3.1 Chapter 4...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
EME5 Homework 3 Solutions October 15, 2010 3 Chapter 4, Problem 1 3.1 Part a False. Some operators are operated from left to right and others are evaluated from right to left depending on their associativity. 4 Chapter 4, Problem 2 4.1 Part e a = (b >> (2 + 4)); 4.2 Part g (a == b) || (x != y) 1
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
5 Chapter 4, Problem 4 5.1 Solution Code #include <stdio.h> int main() { float f1 = 0.2, f2 = 0.5; printf("(f1 * f1 == 0.1) = %d\n", f1*f1 == 0.1); printf("(f1 + f1 == 0.07) = %d\n", f1+f1 == 0.07); return 0; } 5.2 Solution Output (f1*f1 == 0.1) = 0 (f1+f1 == 0.07) = 0 6 Chapter 4, Problem 11 6.1 Part a 4 3 πr 3 (1) 6.2 Part b 4 3 πr 3 (2) 6.3 Part c 9 5 c + 32 (3) 2
Image of page 2
6.4 Part d 9 5 c + 32 (4) 7 Chapter 4, Problem 12 7.1 Part c (4/3.0)*3.14*r*r*r 7.2 Part f (x >= y) && (x >= 0) 7.3 Part i ((1 < x) && (x <= 20)) || ((1 <= y) && (y <= 3)) 8 Chapter 4, Problem 16 8.1 Part b 8.1.1 Solution Code #include <stdio.h> #include <math.h> int main() { /* declare and initialize variables */ double x1 = 4, y1 = 3, x2 = 6, y2 = 5; double sidex, sidey, distance; /* calculate the distances of two sides in X and Y direction */ sidex = x2-x1; sidey = y2-y1; /* calculate the straight-line distance */ distance = sqrt(sidex*sidex + sidey*sidey);
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern