CMSC201 Homework Assignment (Boolean et. all.) Solution
Shapiro's Sections ONLY
1)
a. Always
b. Not O.K.
c. selection B is ok
2)
a. TRUE
b. TRUE
c. FALSE
3)
a 6 b 48 c 12 d 4
---- ---- ---- ----
4)
a 7 b 3 c 12 d 14
---- ---- ---- ----
5)
if (((age>=18) && (age<=26)) && (marital_status == 'S' ||
marital_status == 's' || marital_status == 'D' ||
marital_status == 'd') && (gender == 'M' || gender == 'm'))
printf("Please register with the selective service\n");
6)
if((heading>=0) && (heading<90))
bearing = "north (heading) east";
else if((heading>=90) && (heading<180))
bearing = "south (180.0-heading) east";
else if((heading>=180) && (heading<270))
bearing = "south (heading-180.0) west";
else if((heading>=270) && (heading<=360))
bearing = "north (360.0-heading) west";
7) 50 lines
8)
0
0
0 2
0 3 6
0 4 8 12
0 5 10 15 20
0 6 12 18 24 30
9) n = 2, m = 6, p = 6
10) x = 21, y = 1, z = 23
11)
5 4 3
2 8
6