Write a single statement to accomplish each of the following. Assume that variables c (which stores a character), x, y and z are of type int; variables d, e and f are of type double; variable ptr is of type char * and arrays s1[ 100 ] and s2[ 100 ] are of type char.

a) Convert the character stored in variable c to an uppercase letter. Assign the result to variable c.
b) Determine if the value of variable c is a digit. Use the conditional operator as shown in Fig. 22.18–22.20 to print " is a " or " is not a " when the result is displayed.
c) Convert the string "1234567" to long, and print the value.
d) Determine whether the value of variable c is a control character. Use the conditional operator to print " is a " or " is not a " when the result is displayed.
e) Assign to ptr the location of the last occurrence of c in s1.
f) Convert the string "8.63582" to double, and print the value.
g) Determine whether the value of c is a letter. Use the conditional operator to print " is a " or " is not a " when the result is displayed.
h) Assign to ptr the location of the first occurrence of s2 in s1.
i) Determine whether the value of variable c is a printing character. Use the conditional operator to print " is a " or " is not a " when the result is displayed.
j) Assign to ptr the location of the first occurrence in s1 of any character from s2.
k) Assign to ptr the location of the first occurrence of c in s1.
l) Convert the string "-21" to int, and print the value.


a) ```
c = toupper( c );
```
b) ```
cout << '\'' << c << "\' "
<< ( isdigit( c ) ? "is a" : "is not a" )
<< " digit" << endl;
```
c) ```
cout << atol( "1234567" ) << endl;
```
d) ```
cout << '\'' << c << "\' "
<< ( iscntrl( c ) ? "is a" : "is not a" )
<< " control character" << endl;
```
e) ```
ptr = strrchr( s1, c );
```
f) ```
out << atof( "8.63582" ) << endl;
```
g) ```
cout << '\'' << c << "\' "
<< ( isalpha( c ) ? "is a" : "is not a" )
<< " letter" << endl;
```
h) ```
ptr = strstr( s1, s2 );
```
i) ```
cout << '\'' << c << "\' "
<< ( isprint( c ) ? "is a" : "is not a" )
<< " printing character" << endl;
```
j) ```
ptr = strpbrk( s1, s2 );
```
k) ```
ptr = strchr( s1, c );
```
l) ```
cout << atoi( "-21" ) << endl;
```

Computer Science & Information Technology

You might also like to view...

Case-Based Critical Thinking QuestionsCase 9-1Art's Custom Building has a Web site that is designed to appeal to all sorts of customers. Art wants his site to be compatible even with users who might even still use dialup and older browsers. For his browser compatibility, which encoding should he use?

A. UTF-64 B. UTF-8 C. UTF-10 D. UTF-50

Computer Science & Information Technology

A(n) ____________________ type is the specific category of information that a variable contains.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Compare and contrast a compiler and an interpreter.

What will be an ideal response?

Computer Science & Information Technology

Step 3 in problem solving is to identify alternative ways to solve the problem. This means:

a. To define the knowledge base of all participant b. To write a list of pros and cons for each solution. c. To identify as many solutions as possible to the problem. d. To identify a few solutions to the problem.

Computer Science & Information Technology