0% found this document useful (0 votes)
7 views4 pages

04 Review

Uploaded by

Phạm Lê Huy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

04 Review

Uploaded by

Phạm Lê Huy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Chapter 4 Mathematical Functions, Characters, and Strings

1. Please run the code to find the answer.

2. True.

3. double radians = (PI / 180) * 47

4. double angle = (180 / PI) * PI / 7


False: a call to a function with a nonvoid return type is always a component of an
expression.

5. cout << static_cast<int>('1') << endl;


cout << static_cast<int>('A') << endl;
cout << static_cast<int>('B') << endl;
cout << static_cast<int>('a') << endl;
cout << static_cast<int>('b') << endl;

cout << static_cast<char>(40) << << endl;


cout << static_cast<char>(40) << << endl;
cout << static_cast<char>(40) << << endl;
cout << static_cast<char>(40) << << endl;

cout << static_cast<char>(0X40) << endl;


cout << static_cast<char>(0X5A) << endl;
cout << static_cast<char>(0X71) << endl;
cout << static_cast<char>(0X72) << endl;
cout << static_cast<char>(0X7A) << endl;

6. All are correct character literals.

7. cout << "\\" << endl; cout << "\"" << endl;

8. 49 99 97 Z

9.
A
65
1000.34
1000
1000.34
1000
97
a
10.
b
c
-2

11.
It will be the starting character.

12.
It will be 13.

13.
Use isdigit(ch) to test if a character is a digit.
Use isalpha(ch) to test if a character is a
letter.
Use isupper(ch) to test if a character is an
uppercase letter.
Use islower(ch) to test if a character is an
lowercase letter.
Use isalphanum(ch) to test if a character is a
letter or a digit.

14.
Use tolower(ch) to return a lowercase letter and
use toupper(ch) to return an uppercase letter.

15.
Line 27 tests if the character is between ‘0’ and
‘9’.

16.
The output will be 15.

17.
string city = "Chicago";

18.
cout << s.size() << endl;

19.
s[0] = 'P';

20.
G
false
true
true
true
false
false

21.
Use the getline function to read a string.

20.
Line 13 uses the length() function to return the
string length. Alternatively, you can use the
size() function.

21.
11

22.
include <iomanip>;

23.

24.

25.
26.

27.

28.
To create an object for reading data from file test.txt, use ifstream input("test.txt");

To create an object for writing data to file test.txt, use ofstream output("test.txt");

29. Yes. Use ofstream output("numbers.txt");

30. The existing file will be destroyed.

You might also like