
Concept explainers
(Integer Equivalent of a Character) Here is a peek ahead. In this chapter you learned about integers and the type int. C++ can also represent uppercase letters, lowercase letters and a considerable variety of special symbols. C++ uses small integers internally to represent each different character. The set of characters a computer uses and the corresponding integer representations for those characters are called that computer’s characterset You can print a character by enclosing that character in single quotes, as with
cout «; // print an uppercase A
You can print the integer equivalent of a character using static_cast as follows:
cout « static cast<int>(‘A); // print>’A’as an integer
This is called a castoperation (we formally introduce casts in Chapter 4). When the preceding statementexecutes, it prints the value 65 (on systems that use the ASCII character set). Write a programthat prints the integer equivalent of a character typed at the keyboard. Store the input in a variable oftype char.Test your

Want to see the full answer?
Check out a sample textbook solution
Chapter 2 Solutions
C++ How to Program (10th Edition)
Additional Engineering Textbook Solutions
Vector Mechanics For Engineers
Automotive Technology: Principles, Diagnosis, And Service (6th Edition) (halderman Automotive Series)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Modern Database Management
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Electric Circuits. (11th Edition)
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning




