DOC PREVIEW
UGA CSCI 1301 - PreLab 9

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Pre Lab #9: Exercise Sheet Print out this exercise sheet, complete it and turn it in to your lab instructor before your lab session on Wednesday/Thursday ends. 1) Write a Boolean expression for each of the following statements. Assume that x, y and z are int variables and have been declared. a) 2 times x is greater than 3 times y but less than z. ___________________________________________________________________________ b) x is even. ___________________________________________________________________________ c) y is odd. ___________________________________________________________________________ d) x is odd and y is even. ___________________________________________________________________________ e) One of x and y is even and the other is odd. ___________________________________________________________________________ Hints: i) An integer is odd when the remainder of dividing the integer by 2 is 1. On the other hand, an integer is even when the remainder of dividing the integer by 2 is 0. ii) Use the remainder operator (%). 2) Write a Boolean expression for each of the following sentences. Assume that year is an int variable already declared that stores an integer greater than or equal to zero. a) year is a century. ___________________________________________________________________________ b) year is a century and is divisible by 400. ___________________________________________________________________________c) year is not a century and divisible by 4. ___________________________________________________________________________ d) year is not a century and is divisible by 4 or a century divisible by 400. ___________________________________________________________________________ Hints: • A century is 100 years. • An integer a is divisible by another integer b when the remainder of a divided by b is zero. • Use the remainder (%) operator to compute the remainder. 3) For each of the Boolean expressions below, circle its truth-value. int a=5, b=3, c=9; boolean e=true, f=false; a) c % b > a - b true false b) e && f || true true false c) a > c && b + 6 < c || b !=c true false d) (a > c || b + 8 >= c) && b !=c || !e true false e) ! (a == b) || e && b < c && a<=c || !f true false f) b !=c && (a > c || b + 8 >= c) || !f true


View Full Document

UGA CSCI 1301 - PreLab 9

Documents in this Course
Load more
Download PreLab 9
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view PreLab 9 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view PreLab 9 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?