CSCI 240 - Possible Questions for Quiz 6

  1. (2 points) The data type char and the data type __________ are often interchageable in C++.

    1. double
    2. float
    3. int
    4. string
  2. (2 points) What will happen if a char is cout'd as an int?

    1. the character will be displayed
    2. the ASCII value of the character will be displayed
    3. it will not compile
    4. it will produce a run-time error
  3. (2 points) What is the ASCII value of the character '1'?

  4. (2 points) What is the ASCII value of the character 'c'?

  5. (2 points) Write a cout statement to display the ASCII value of the character stored in a char variable called ch. Assume that ch has been properly declared and contains a value.

  6. (2 points) Explain what tolower() does to a character. The answer should include the argument(s) that are passed to tolower() (if any) and what it returns.

  7. (2 points) Write a C++ statement that takes the digit character in the char variable ch and changes it to its integer representation and saves the result in the integer variable intVal. So if ch contains '4', then intVal should contain the value 4. Assume that ch and intVal have been properly declared.

  8. (2 points) Write a switch statement to print out a string depending on the value of a char variable called ch. If

    Assume that ch has been properly declared and contains a value.