(5/5)

# Given the variable declarations, evaluate the following compound conditions. Indicate with YES or NO next to each of the six numbers whether that simple condition will be evaluated.

INSTRUCTIONS TO CANDIDATES

Problem Solving and Programming

1) [4 points] Given the variable declarations, evaluate the following compound conditions.  Indicate with YES or NO next to each of the six numbers whether that simple condition will be evaluated.  Also, indicate the value of the compound condition.

int d = 7;

int e = 2;

1.  a) d != 5 || d != 6 || d != 7 || d != 8 || d != 9 || d != 10

1          2          3          4           5          6

Simple conditions ®

1)

2)

3)

4)

5)

6)

Compound condition value: __________

1. b) e != 5 && e != 4 && e != 3 && e != 2 && e != 1 && e != 0

1               2               3              4               5              6

Simple conditions ®

1)

2)

3)

4)

5)

6)

Compound condition value: __________

2) [3 points] The most common logical operators are AND, OR, and NOT, but there are other ones.  Research and complete truth tables for the following operators:

1. a) Exclusive or (XOR)

 “xor” operator truth table Left side Right side Result

1. b) Implication (®)

 “implication” operator truth table Left side Right side Result

1. c) Biconditional («)

 “biconditional” operator truth table Left side Right side Result

3) [6 points] Prompt for and read a single upper-case element symbol into char variable sym.  Print the corresponding element and atomic number.  Print an error message if any other character is entered.  Write both if statement and switch statement versions.

 Element Symbol Atomic number Boron B 5 Carbon C 6 Nitrogen N 7 Oxygen O 8

1. a) if statement version

1. b) switch statement version

4) [4 points] Write a validation loop that prompts for and gets from the user a string that is at least five characters in length.  If the string is outside that length range, print a message including the string and prompt the user again.  Declare string variable str to hold the string.  Allow the user to enter spaces.

5) [7 points] Write the number of for statement loops that will be performed for each of the following:

 Initialization Condition Update Loops? a) i = -4 i <= 4 i = i + 1 b) i = 20 i < 30 i = i + 4 c) i = 7 i <= 7 i = i – 1 d) i = 15 i > 16 i = i * 2 e) i = 0 i < 50 i = i – 3 f) i = 24 i > 12 i = i – 2 g) i = 17 i != 8 i = i – 2

6) [1 point] Why should the continue statement rarely be used?

(5/5)

## Related Questions

##### . Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

##### . The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

##### . Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

##### . SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

##### . Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Hire Me

Hire Me