COMP 122 COMP122 Week 2 Homework Assignment Solution

COMP 122 COMP122 Week 2 Homework Assignment Solution

soffix

  • $12.99


COMP 122 Week 2 Homework

Complete the following problems.

 

1. Suppose you are given the following variable declarations:

 

int x, y;

char ch;

 

   What values (if any) are assigned to x, y, and ch after each of these statements execute?

   Assume that the input to each statement is the same:5  28  36

2. Suppose you are given the following variable declarations:

 

int x, y;

char ch;

 

   What values (if any) are assigned to x, y, and ch after each of these statements execute?

   Assume that the input to each set of statements is as follows:

 

3. Suppose you are given the following variable declarations:

 

int x, y;

double z;

char ch;

4. Write a C++ statement that uses the manipulator 'setfill' to output a line containing 35 asterisk characters.

5. What is the output from the following statements?

6. Suppose that you have the following variable declarations:

7. What is the output of the following code fragment?

8. Given a char variable called gender, write C++ statements to output "Male" if gender contains upper or lower case M, "Female" if it contains upper or lower case F, or "Invalid Gender" if it contains anything else. Use if / else if statements.

9. Given a char variable called gender, write C++ statements to out "Male" if gender contains upper or lower case M, "Female" if it contains upper or lower case F, or "Invalid Gender" if it contains anything else. Use a switch statement.

10. What is the value of the beta variable after the following code executes?


We Also Recommend


Sale

Unavailable

Sold Out