84.5k views
1 vote
Assume c is a char variable. What value does c hold after each of the following statements executes?

Statement Contents of c
1. c = toupper('a');___________
2. c = toupper('B');___________
3. c = tolower('D');___________
4. c = toupper('e');___________
1. 'A'
2. 'B'
3. 'd'
4. 'E

User Hiroga
by
8.8k points

2 Answers

3 votes

Final answer:

After executing each statement, the value of c changes based on the specified toupper or tolower functions.

Step-by-step explanation:

After each statement executes:

  • Statement 1: c holds the value 'A'
  • Statement 2: c holds the value 'B'
  • Statement 3: c holds the value 'd'
  • Statement 4: c holds the value 'E'

User Maccullt
by
8.0k points
2 votes

Final answer:

The char variable c will hold the uppercase or lowercase equivalent of the characters passed to the toupper() or tolower() functions in C programming language, respectively resulting in 'A', 'B', 'd', and 'E'.

Step-by-step explanation:

The student is asking about the C programming language and specifically about the behavior of the character functions toupper() and tolower(). These functions are used to convert a character to uppercase or lowercase respectively.

  1. When c = toupper('a') is executed, 'A' is the value that c will hold since 'a' is converted to uppercase.
  2. For c = toupper('B'), 'B' will be the value of c because 'B' is already in uppercase, and the function will not change it.
  3. c = tolower('D') will result in c holding the value 'd', as 'D' is converted to lowercase.
  4. Lastly, executing c = toupper('e') will cause c to hold the value 'E', as 'e' is converted to uppercase.

User Fremorie
by
7.9k points