Practical C++ Programming by manish baranwal

Start from the beginning
                                        

performed. If both operands are integers then an integer divide is done.

20. A thermos keeps hot things hot and cold things cold. How does it know which one to do?

21. The standard character set, ASCII, handles 128 characters. Only 95 of these can be typed in

using the keyboard. What does a C++ programmer use to specify the none printing characters?

The backslash character (called the escape character sometimes) is used to indicate a

special character. For example “\b” is used to indicate the non-printing “backspace”

character.

22. Define “character variable” and show how a character variable can be declared and used.

A variable that can hold a single character.

char a_char; // Sample character declaration

//...

a_char = 'x';

Characters may also be used as “very short integers.” That is, numbers in the range of 0-

127. Example:

a_char = 5;

23. What are the possible value of a boolean (bool) variable?

true and false .

(Do NOT use "True", "False", "TRUE", or "FALSE". If you see these they are legacy

constants for ancient code.)

Advanced Questions

The answers to these may require resources outside the scope of this book.

24. What is the value of 4.5 % 3.2?

25. Why are real numbers called floating point numbers?

26. What “floats” in a floating point number?

27. What is the biggest integer variable that you can have on your machine?

28. What is the biggest floating point variable that you can have on your machine?

29. Why are integer variables exact and floating point variables inexact?

Page 13

Chapter 5: Arrays,

Qualifiers, and Reading

Numbers

That mysterious independent variable of political calculations, Public Opinion.

— Thomas Henry Huxley

Teacher’s Notes

In the previous chapter students were introduced to the simple variable and the output statement. In this

chapter we expand on that knowledge by introducing them to the array type and the input statement

std::cin.

C++ has two basic types of strings. The first, the C++ Style String is a class found in the string header

file:

#include <string>

std::string name = "Steve Oualline";

The other type is the C Style String which is created from an array of characters.

char name[50] = "Steve Oualline";

C++ style strings are introduced first since they are simpler to use and less error prone than C style

You've reached the end of published parts.

⏰ Last updated: Nov 04, 2012 ⏰

Add this story to your Library to get notified about new parts!

Practical C++ Programming by manish baranwalWhere stories live. Discover now