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. - ✔️✔️intVal = ch - '0';
What will happen if a char is cout'd as an int? - ✔️✔️the ASCII value of the character
will be displayed
What is the ASCII value of the character '1'? - ✔️✔️49
What is the ASCII value of 'c'? - ✔️✔️99
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. -
✔️✔️char ch;
cout << (int)ch;
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. - ✔️✔️tolower() takes a
character that is passed
Write a switch statement to print out a string depending on the value of a char variable
called ch. If
~ ch is 'a' print "excellent"
~ ch is 'b' print "good"
~ ch is 'c' print "ok"
~ if ch is anything else, print "invalid"
Assume that ch has been properly declared and contains a value. - ✔️✔️switch (ch)
{
case 'a': cout << "excellent";
break;
case 'b': cout << "good";
break;
case 'c': cout << "ok";
break;
default: cout << "invalid";
}
Declare an array named AR to hold 4 integers and fill it with the numbers 2, 4, 6, and 8.
- ✔️✔️int AR[4] = { 2, 4, 6, 8};