100% found this document useful (2 votes)
78 views

C++ Programming From Problem Analysis to Program Design 8th Edition Malik Solutions Manual download

The document provides information about the C++ Programming: From Problem Analysis to Program Design, 8th Edition, including a solutions manual and various test banks for related textbooks. It outlines the basics of C++ programming, covering key concepts such as data types, functions, and arithmetic operations, along with teaching tips and objectives for educators. Additionally, it emphasizes the importance of understanding programming syntax and semantics, as well as the proper structuring of C++ programs.

Uploaded by

mineomeigsuj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
78 views

C++ Programming From Problem Analysis to Program Design 8th Edition Malik Solutions Manual download

The document provides information about the C++ Programming: From Problem Analysis to Program Design, 8th Edition, including a solutions manual and various test banks for related textbooks. It outlines the basics of C++ programming, covering key concepts such as data types, functions, and arithmetic operations, along with teaching tips and objectives for educators. Additionally, it emphasizes the importance of understanding programming syntax and semantics, as well as the proper structuring of C++ programs.

Uploaded by

mineomeigsuj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

C++ Programming From Problem Analysis to Program

Design 8th Edition Malik Solutions Manual


install download

https://testbankmall.com/product/c-programming-from-problem-
analysis-to-program-design-8th-edition-malik-solutions-manual/

Download more testbank from https://testbankmall.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Solution manual for C++ Programming: From Problem Analysis


to Program Design, 6th Edition – D.S. Malik

https://testbankmall.com/product/solution-manual-for-c-programming-
from-problem-analysis-to-program-design-6th-edition-d-s-malik/

testbankmall.com

Test Bank for C++ Programming: From Problem Analysis to


Program Design, 6th Edition – D.S. Malik

https://testbankmall.com/product/test-bank-for-c-programming-from-
problem-analysis-to-program-design-6th-edition-d-s-malik/

testbankmall.com

Solution Manual for C# Programming: From Problem Analysis


to Program Design, 5th Edition, Barbara Doyle

https://testbankmall.com/product/solution-manual-for-c-programming-
from-problem-analysis-to-program-design-5th-edition-barbara-doyle/

testbankmall.com

Test Bank for Introduction to Clinical Psychology 8/E 8th


Edition Geoffrey P. Kramer, Douglas A. Bernstein, Vicky
Phares
https://testbankmall.com/product/test-bank-for-introduction-to-
clinical-psychology-8-e-8th-edition-geoffrey-p-kramer-douglas-a-
bernstein-vicky-phares/
testbankmall.com
Test bank for Cornerstones of Cost Management 3rd Edition
by Hansen

https://testbankmall.com/product/test-bank-for-cornerstones-of-cost-
management-3rd-edition-by-hansen/

testbankmall.com

Test Bank for Introduction to Risk Management and


Insurance 10th Edition by Dorfman

https://testbankmall.com/product/test-bank-for-introduction-to-risk-
management-and-insurance-10th-edition-by-dorfman/

testbankmall.com

Test bank for Strategic Management: Theory & Cases: An


Integrated Approach 12th Edition by Hill

https://testbankmall.com/product/test-bank-for-strategic-management-
theory-cases-an-integrated-approach-12th-edition-by-hill/

testbankmall.com

Test Bank for Java Software Solutions, 9th Edition John


Lewis

https://testbankmall.com/product/test-bank-for-java-software-
solutions-9th-edition-john-lewis/

testbankmall.com

Test Bank for Diversity in Organizations 3rd Edition Bell

https://testbankmall.com/product/test-bank-for-diversity-in-
organizations-3rd-edition-bell/

testbankmall.com
Test Bank for Introduction to Sports Medicine and Athletic
Training 3rd Edition by France

https://testbankmall.com/product/test-bank-for-introduction-to-sports-
medicine-and-athletic-training-3rd-edition-by-france/

testbankmall.com
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-2
• Key Terms

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-3

Lecture Notes

Overview
Chapter 2 teaches your students the basics of C++. Learning a programming language is
similar to learning to be a chef or learning to play a musical instrument. All three
require direct interaction with the tools; in other words, you cannot become proficient
by simply reading books on the topics. In this chapter, your students will begin
acquiring a fundamental knowledge of C++ by learning about data types, functions,
identifiers, assignment statements, arithmetic operations, and input/output operations.
They will then write and test programs using these concepts to verify their knowledge
of the material.

Objectives
In this chapter, the student will:
• Become familiar with the basic components of a C++ program, including functions,
special symbols, and identifiers
• Explore simple data types
• Discover how to use arithmetic operators
• Examine how a program evaluates arithmetic expressions
• Become familiar with the string data type
• Learn what an assignment statement is and what it does
• Learn about variable declaration
• Discover how to input data into memory using input statements
• Become familiar with the use of increment and decrement operators
• Examine ways to output results using output statements
• Learn how to use preprocessor directives and why they are necessary
• Learn how to debug syntax errors
• Explore how to properly structure a program, including using comments to document a
program
• Become familiar with compound statements
• Learn how to write a C++ program

Teaching Tips
Introduction
1. Define the terms computer program and programming.

2. Use the recipe analogy to give students an idea of the process of programming.

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-4

A Quick Look at a C++ Program

1. Note that every C++ program must have a function called main. Use Example 2-1 to
illustrate a basic main function. Walk through this example and point out the meaning
of each line.

2. Discuss the purpose of an output statement and what it produces.

3. Point out the use of comments.

4. Briefly introduce the #include directive.

5. Use Figure 2-1 to describe the various parts of a C++ program.

Teaching Reassure students that although most of this example probably looks confusing,
Tip they will soon understand it and be comfortable with it.

6. Use Figures 2-2 and 2-3 to describe how memory is allocated and used to store values.

The Basics of a C++ Program


1. Explain that a C++ program is essentially a collection of one or more subprograms,
called functions. Note that although many functions are predefined in the C++ library,
programmers must learn how to write their own functions to accomplish specific tasks.

2. Define the terms syntax rules and semantic rules as they relate to a programming
language and explain the difference between the two.

Teaching Emphasize that compilers check for syntax but not semantic errors. Give an
Tip example of each type of error.

Comments

1. Use the program in Example 2-1 to describe the use and importance of comments.
Stress that comments are for the reader, not for the compiler.

2. Describe the two forms of comments shown in the textbook.

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-5

The importance of documenting a program cannot be underestimated. It is highly


Teaching
important for ensuring that the next programmer to be responsible for
Tip
maintaining the code will be able to understand what the code is supposed to do.

Special Symbols

1. Explain that the C++ programming language consists of individual units called tokens,
and these are divided into special symbols, word symbols, and identifiers.

2. Go over some of the special symbols in C++, including mathematical symbols,


punctuation marks, the blank symbol, and double characters that are regarded as a
single symbol.

Reserved Words (Keywords)

1. Discuss the word symbols, or keywords, used in C++, using Appendix A as a guide.
Emphasize that C++ keywords are reserved and cannot be redefined for any other
purpose with a program.

Identifiers

1. Define the term identifier as a name for something, such as a variable, constant, or
function.

2. Discuss the rules for naming identifiers in C++. Also note that C++ is a case-sensitive
language.

3. Use Table 2-1 to review the rules of identifier naming.

Discuss the difference between C++ conventions and rules. For example, it is a
Teaching
rule that a mathematical symbol cannot be used in an identifier name. However,
Tip
it is a convention to begin an identifier with a lowercase letter.

Whitespaces

1. Explain that whitespaces (which include blanks, tabs, and newline characters) are used
to separate special symbols, reserved words, and identifiers.

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-6

Data Types
1. Explain that C++ categorizes data into different types in order to manipulate the data in
a program correctly. Although it may seem cumbersome at first to be so type-conscious,
emphasize that C++ has these built-in checks to guard against errors.

Explain that C++ is called a strongly typed language because it checks for
Teaching operations between inconsistent data types. This results in more robust and error-
Tip free programs. Demonstrate how C++ checks for data types with a simple
program that attempts to add a string and a numeric value.

2. Define the term data type as a set of values together with a set of operations.

3. Mention that C++ data types fall into three categories: simple data types, structured data
types, and pointers. Only the first type is discussed in this chapter.

Simple Data Types

1. Describe the three categories of simple data types in C++: integral, floating-point, and
enumeration.

2. Mention the eleven categories of integral data types. Explain why C++ (and many other
languages) has so many categories of the same data type. In addition, discuss the rules
involving the use of integral types.

4. Explain the purpose of the bool data type.

5. Discuss the char data type, including its primary uses. Mention commonly used ASCII
characters and their predefined ordering. Explain that a char data type is enclosed in
single quotation marks, and note that only one symbol may be designated as a character.

6. Use Table 2-2 to summarize the three simple data types. Point out the difference in the
amount of memory storage required, but inform students that this is system-dependent.

Floating-Point Data Types

1. Use Table 2-3 to explain how C++ represents real, or floating-point, numbers. Mention
the three categories of data types to represent real numbers (float, double, and
long double), and explain when to use each type.

2. Define the terms precision, single precision, and double precision.

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-7

Demonstrate how to find the values of float and double on a particular


Teaching system by running the program with the header file <cfloat> in Appendix F.
Tip Encourage students to try running this program on their own computers and
comparing the results.

Quick Quiz 1
1. What is an enumeration type?
Answer: C++’s method for allowing programmers to create their own simple data types

2. The maximum number of significant digits in a number is called the


.
Answer: precision
3. The data type has only two values: true and false.
Answer: bool

4. The data type, the smallest integral data type, is used to


represent characters.
Answer: char

Data Types and Variables, and Assignment Statements


1. Explain that the declaration of a variable requires that the data type be specified.

2. Explain the concept and syntax of an assignment.

Arithmetic Operators, Operator Precedence, and Expressions


1. Discuss the five arithmetic operators in C++ that are used to manipulate integral and
floating-type data types.

2. Define the terms unary and binary operators, and discuss the difference between them.

Order of Precedence

1. Review operator precedence rules, as C++ uses these rules when evaluating
expressions. Explain that parentheses can be used to override the order of operator
precedence.

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-8

Expressions

1. This section discusses integral and floating-point expressions in detail.

2. Describe the three types of arithmetic expressions in C++.

3. Use Examples 2-6 and 2-7 to clarify how C++ processes expressions.

Mixed Expressions

1. Discuss the two rules for evaluating mixed expressions and illustrate these rules in
practice using Example 2-8.

Quick Quiz 2
1. A(n) operator has only one operand.
Answer: unary

2. You can use to override the order of precedence rules.


Answer: parentheses

3. Describe the associativity of arithmetic operators.


Answer: Unless there are parentheses, the associativity of arithmetic operators is said to
be from left to right.

4. An expression that has operands of different data types is called a(n)


.
Answer: mixed expression

Type Conversion (Casting)


1. Explain how C++ avoids the hazards that result from implicit type coercion, which
occurs when one data type is automatically changed into another data type.

2. Illustrate the form of the C++ cast operator using Example 2-9.

Students may feel a bit overwhelmed after the discussion of the static_cast
operator. Ask them to run the program from Example 2.9. They should
Teaching
experiment with removing the static_cast operator from various statements,
Tip
as well as changing the variable values. Ask them to report on any unpredictable
results.

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-9

string Type

1. Introduce the C++ data type string, which is a programmer-defined data type
available in the C++ library. Define a string as a sequence of zero or more characters.

2. Define the terms null string or empty string.

3. Discuss how to determine the length of a string, as well as the position of each character
in a string.

Teaching Emphasize that the first position of a character in a string is 0, not 1. This will be
Tip helpful when manipulating both strings and arrays later on the text.

Variables, Assignment Statements, and Input Statements


1. Explain that data for a C++ program must be input into main memory. Mention the two-
step process to store data in the computer’s memory.

Allocating Memory with Constants and Variables

1. Emphasize that when allocating memory, the programmer must instruct the computer
which names to use for each memory location as well as what type of data to store in
those memory locations.

2. Define the term named constant and describe the syntax for declaring a named constant.
Use Example 2-11 to illustrate the naming conventions for named constants. Explain
why named constants are used in programs.

3. Define the term variable and use Example 2-12 to illustrate the syntax for declaring
single and multiple variables.

4. Give a formal definition of a simple data type.

Putting Data into Variables

1. Mention the two ways you can place data in a variable in C++.

Assignment Statement

1. Discuss the C++ assignment statement, including its syntax, variable initialization, and
the associativity rules of the assignment operator.

2. Step through Example 2-13 to illustrate how assignment statements operate in C++.

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-
10
3. Use Example 2-14 to discuss the importance of doing a walk-through (tracing values
through a sequence of steps) when writing code.

Teaching Building a table showing the values of variables at each step of the program is
Tip very helpful for students to understand the nature of variables.

Saving and Using the Value of an Expression

1. Explain the steps involved in saving the value of an expression using Example 2-15.

Declaring and Initializing Variables

1. Explain that when a variable is declared, C++ may not automatically put a meaningful
value in it.

2. Emphasize that it is a good practice to initialize variables while they are being declared.
Use one or more examples to illustrate how to do this in C++.

Input (Read) Statement

1. This section teaches your students to read data into variables from a standard input
device. Define and explain the use of the C++ object cin and the stream extraction
operator >>.

2. Step through Examples 2-16 through 2-18 to illustrate how to read in numeric and string
data.

Variable Initialization

1. Reiterate that a variable can be initialized either through an assignment statement or a


read statement. Explain why the read statement option is more versatile. Use Example
2-19 to illustrate both types of initialization.

Programmers (and instructors) have various approaches or preferences regarding


variable declaration and initialization. Share your views on the topic. Do you
Teaching
think the best approach is to always initialize variables for consistency? Do you
Tip
prefer initializing variables directly before the block of code that uses them, or
initializing them during declaration?

Quick Quiz 3
1. What is a named constant?

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-10

Answer: A memory location whose content is not allowed to change during program
execution

2. What is the syntax for declaring single or multiple variables?


Answer: dataType identifier, identifier, …;

3. True or False: If you refer to an identifier without declaring it, the compiler will
generate an error message.
Answer: True

4. A variable is said to be _ the first time a value is placed in it.


Answer: initialized

Increment and Decrement Operators

1. Explain the purpose of the C++ increment (++) and decrement (--) operators.

2. Discuss how pre and post versions of these operators affect the results in a program.
Use Example 2-20 to help explain the difference between these versions.

Verify that students are comfortable with using pre- and post-
Teaching
increment/decrement operators correctly, as it will be useful when working with
Tip
control structures.

Output

1. Review how the C++ output statement is coded with the cout object and stream
insertion operator (<<). Review the role of the endl manipulator in output statements
as well.

2. Discuss the use of escape characters (see Table 2-4), such as the newline character, to
format output. Demonstrate how to format output with Examples 2-21 through 2-26.

Outputting strings can be confusing at first. Talk about the various methods to
Teaching deal with several lines of string output, and give your opinion as to the best
Tip approach. Emphasize that the Enter key cannot be used to break up a long string
into two lines.

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-11

Preprocessor Directives
1. Explain the role of the preprocessor in C++. Discuss the use of header files and the
syntax for including them in a C++ program.

Teaching Show your students some of the available operations in the <cmath> header.
Tip Here is one Web site with a description:
http://www.cplusplus.com/reference/cmath/

namespace and Using cin and cout in a Program

1. Briefly explain the purpose of the namespace mechanism in ANSI/ISO Standard


C++. Discuss the std namespace and how it relates to the <iostream> header
file.

2. Review the using namespace std; statement and its usefulness in programs
using cin and cout statements.

Using the string Data Type in a Program

1. Mention that the <string> header must be included in C++ programs using the
string data type.

Creating a C++ Program

1. Discuss the role of the function main in a C++ program. Go over the syntax of a main
function, including declaration, assignment, executable, and return statements. Mention
that named constant definitions and preprocessor directives are written before the main
function.

2. Spend some time stepping through Examples 2-27 through 2-29. Verify that students
understand each line of code in Example 2-29.

Debugging: Understanding and Fixing Syntax Errors


1. Review the sample program on page 84 and the compiler output that is generated when
compiling the program. Walk through the various syntax errors and explain how each
one should be fixed. Note that a syntax error on one line may be the cause of a compiler
error on the following line.

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-12

Debugging is one of the most important skills a professional programmer


Teaching
acquires. Stress to students the importance of learning how to debug their own
Tip
programs, including the verification of the results.

Program Style and Form


1. This section covers basic C++ syntax and semantic rules. Review these rules with your
students in order for them to feel comfortable writing a complete functioning C++
program.

Syntax

1. Remind students that syntax rules define what is legal and what is not.

2. Discuss some common syntax errors. Emphasize that syntax errors should be corrected
in the order in which the compiler lists them.

Use of Blanks

1. Discuss when blanks should and should not be used in a C++ program.

Use of Semicolons, Brackets, and Commas

1. Explain the purpose and meaning of semicolons, brackets, and commas in C++
programs. Define the term statement terminator.

Semantics

1. Define the term semantics.

2. Reiterate that a program may run without compiler errors and still have semantic errors
that generate incorrect results. Use the example in the text to illustrate.

Naming Identifiers

1. Mention the conventions for naming identifiers, including self-documenting identifiers


and run-together words.

Prompt Lines

1. Define the term prompt lines.

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-13

2. Explain why well-written prompt lines are essential for user input.

Documentation

1. Discuss why documenting a program through comments is critical to understanding and


modifying the program at a later time.

Form and Style

1. Explain the purpose behind formatting and indentation conventions in source code. Use
Example 2-30 to illustrate.

As with naming conventions, discuss your own preferences in terms of form and
Teaching style in programming. Use the programming examples at the end of the chapter
Tip to talk about various stylistic elements. Discuss the value of the “art” of
programming.

Quick Quiz 4
1. True or False: The semantic rules of a language tell you what is legal and what is not
legal.
Answer: False

2. The semicolon is also called the .


Answer: statement terminator

3. How can you make run-together words easier to understand?


Answer: Capitalizing the beginning of each new word; or inserting an underscore before
each new word

4. Why are comments important in a program?


Answer: A well-documented program is easier to understand and modify, even a long
time after you originally wrote it. You use comments to document programs. Comments
should appear in a program to explain the purpose of the program, identify who wrote
it, and explain the purpose of particular statements.

More on Assignment Statements


1. Define the terms simple assignment statement and compound assignment statement.

2. Define the C++ compound operators (+=, -=, *=, /=, and %=) and explain how and
why compound assignment statements are used in C++ programs. Use Example 2-31 to
illustrate this.

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-14

3. Step through the “Convert Length” and “Make Change” Programming Examples to
help the students consolidate all the information from this chapter.

Class Discussion Topics


1. As mentioned in this chapter, C++ predefined identifiers such as cout and cin can be
redefined by the programmer. However, why is it not wise to do so?

2. The text mentioned that the char data type can be cast into an int. What are some
possible uses of this functionality?

Additional Projects
1. Learn and report on various compiler errors by modifying one or two of the programs in
this chapter. Try to compile the program. What happens when you fail to initialize a
value for a named constant? What are the error messages when you use a numeric or
string constant in an expression without first giving it a value? Finally, what happens
when you initialize a char data type with a character enclosed in double quotes?

2. Use one of the programs in this chapter to test for invalid user input. The program
should compile with no errors. What happens when you enter an unexpected value
(such as an incorrect data type) when prompted for user input? Test with several sets of
invalid data and document your findings.

Additional Resources
1. C++ Examples:
https://developers.google.com/edu/c++/getting-started

2. Basic Input/Output:
http://www.cplusplus.com/doc/tutorial/basic_io/

3. C++ Programming Style Guidelines:


http://geosoft.no/development/cppstyle.html

4. Strong vs. Weak Typing:


http://www.artima.com/intv/strongweak.html

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-15

Key Terms
Arithmetic expression: an expression constructed using arithmetic operators and
numbers
Assignment operator: =; assigns whatever is on the right side to the variable on the left
side
Associativity: the associativity of arithmetic operators is said to be from left to right
Binary operator: an operator that has two operands
Cast operator (type conversion, type casting): used to explicitly convert one data type
to another data type
Character arithmetic: arithmetic operation on char data
Collating sequence: a predefined ordering for the characters in a set
Compound assignment statement: statements that are used to write simple assignment
statements in a more concise notation
Computer program: a sequence of statements whose objective is to accomplish a task
Data type: a set of values together with a set of operations
Declaration statements: statements that are used to declare things, such as variables
Decrement operator: --; decreases the value of a variable by 1
Double precision: values of type double
Enumeration: a user-defined data type
Executable statements: statements that perform calculations, manipulate data, create
output, accept input, and so on
Floating-point: a data type that deals with decimal numbers
Floating-point (decimal) expression: an expression in which all operands in the
expression are floating-point numbers
Floating-point notation: a form of scientific notation used to represent real numbers
Function (subprogram): a collection of statements; when activated, or executed, it
accomplishes something
Identifier: a C++ identifier consists of letters, digits, and the underscore character (_); it
must begin with a letter or underscore
Implicit type coercion: when a value of one data type is automatically changed to
another data type
Increment operator: ++; increases the value of a variable by 1
Initialized: the first time a value is placed in the variable
Input (read) statement: a statement that places data into variables using cin and >>
Integral: a data type that deals with integers, or numbers, without a decimal part
Integral expression: an expression in which all operands are integers
Keyword: a reserved word
Mixed expression: an expression that has operands of different data types
Named constant: a memory location whose content is not allowed to change during
program execution
Null (empty) string: a string containing no characters
Operands: numbers appearing in an arithmetic expression
Output statement: an output on the standard output device via cout and <<

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
C++ Programming: From Problem Analysis to Program Design, Eighth Edition 2-16

Post-decrement: has the syntax variable--


Post-increment: has the syntax variable++
Precision: the maximum number of significant digits
Pre-decrement: has the syntax –-variable
Predefined (standard) function: a function that is already written and provided as part
of the system
Pre-increment: has the syntax ++variable
Preprocessor: a program that carries out preprocessor directives
Programming: the process of planning and creating a program
Programming language: a set of rules, symbols, and special words
Prompt lines: executable statements that inform the user what to do
Reserved words (keywords): word symbols in a programming language that cannot be
redefined in any program
Run-together word: an identifier that is composed of two or more words that are
combined without caps or underscores
Self-documenting identifiers: identifiers that describe the purpose of the identifier
through the name
Semantic rules: rules that determine the meaning of the instructions
Semantics: a set of rules that gives meaning to a language
Simple assignment statement: a statement that uses only the assignment operator to
assign values to the variable on the left side of the operator
Simple data type: the variable or named constant of that type can store only one value
at a time
Single precision: values of type float
Source code: consists of the preprocessor directives and program statements
Source code file (source file): a file containing source code
Statement terminator: the semicolon
Stream extraction operator: >>; takes information from a stream and puts it into a
variable
Stream insertion operator: <<; takes information from a variable and puts it into a
stream
String: a sequence of zero or more characters
Syntax rules: rules that describe which statements (instructions) are legal, or accepted
by the programming language, and which are not legal
Token: the smallest individual unit of a program written in any language
Unary operator: an operator that has only one operand
Variable: a memory location whose content may change during program execution
Walk-through: the process of tracing values through a sequence

© 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Chapter 2
1. a. false; b. false; c. true; d. true; e. false; f. false; g. true; h. true; i. false; j. false; k. true; l. false
2. b, d, e, f
3. b, e
4. A keyword is a reserved word and is defined by the system. A keyword cannot be redefined in a
program. A user-defined identifier can be redefined.
5. The identifiers quizNo1 and quizno1 are not the same. C++ is case sensitive. The fifth letter of
quizNo1 is uppercase N while the fifth character of quizno1 is lowercase n. So these identifiers
are different
6 . a. 22
b. 2
c. 14
d. 8
e. 7.00
f. 21
g. 20
h. 0.00
i. 15.50

7. a. 7
b. 5.50
c. -1.00
d. Not possible. Both the operands of the operator % must be integers. y + z is of type double. Both
operands, y + z and x, of %V must be integers.
e. 13.50
f. 1
g. Not possible. Both the operands of the operator % must be integers. Because the second operand, z,
is a floating-point value, the expression is invalid.
h. 3.00

8. a, b, c, e, i, j, and k are valid;


d, f, and g are invalid because the left side of an expression must be a variable. h is invalid because the
operands of the mod operator must be integers.
9. x = 9, y = 5, z = 3, w = -3
10. Variable declarations in Lines 1, 6, and 7 are correct.
Variable declaration in Line 2 is incorrect. Now, B+ is a string, so it must be enclosed in double
quotes mark. Also, grade is a char variable and a string cannot be assigned to a char variable. A
correct declaration is:

7
char grade = 'B'; //Line 2

Variable declaration in Line 3 is incorrect because the left side of the assignment operator must be a
variable, and the semicolon at the end of the statement is missing. A correct declaration is:
double num = 28.5; //Line 3

The variable declaration in Line 4 is incorrect because strings are enclosed in double quotation marks.
A correct declaration is:
string message = "First C++ course"; //Line 4

The variable declaration in Line 5 is incorrect because the value assigned to age must be an int value.
A correct declaration is:
int age = 18; //Line 5

11. a and c are valid


12. a. int x, y;
x = 25;
y = 18;
b. int temp = 10;
char ch = 'A';
c. x = x + 5;
d. double payRate = 12.5;
e. tempNum = firstNum;
f. temp = x;
x = y;
y = temp;
g. cout << x << " " << y << " " << x + 12 / y - 18 << endl;
h. char grade = 'A';
i. int num1, num2, num3, num4;
j. x = static_cast<int>(z + 0.5);

13. a. 9.0 / 5 * C + 32
b. static_cast<int>('+')
c. static_cast<int>(x + 0.5)
d. str = "C++ Programming is exciting"
e. totalInches = 12 * feet + inches
f. i++, ++i, or i = i + 1;
g. v = 4 / 3 * (3.1416 * r * r *r);
h. s = 2* (3.1416 * r * *r) + 2 * (3.1416 * r) * h;
i. a + (b – c) / d * (e * f – g * h)
j. (–b + (b * b – 4 * a * c)) / (2 * a)

8
14. x = 1
y = 102
z = 15
w = 44
15. x = 101
y = 11
z = 104
w = 159.00
t = 81.50
16. a. x = 18, y = 5, z = 4
b. 5 * x - y = 85
c. Product of 18 and 4 is 72
d. x - y / z = 17
e. 18 square = 324

17. a. 1000
b. 42.50
c. 1.25
d. 11.00
e. 9
f. 88.25
g. -2.00

18. a. cout << endl; or cout << "\n"; or cout << '\n';
b. cout << "\t";
c. cout << "\"";

19. a and c are correct


20.
a. char grade = '*';
b. double salesTax = 0.05;
c. int numOfJuiceBottles = 0;
d. double billingAmount = 0.0;
e. double gpa = 0.0;

9
21. a. int num1;
int num2;
b. cout << "Enter two numbers separated by spaces." << endl;
c. cin >> num1 >> num2;
d. cout << "num1 = " << num1 << ", num2 = " << num2
<< ", 2 * num1 – num2 = " << 2 * num1 – num2 << endl;

22. A correct answer is:


#include <iostream>
#include <string>

using namespace std;

const double DECIMAL = 5.50;


const string blanks = " ";
double PAY_RATE = 10.75;

int main()
{
int height, weight;
double discount;
double billingAmount;
double bonus;
int hoursWorked = 45;
double price;

height = 6;
weight = 156;

cout << height << " " << weight << endl;

discount = (2 * height + weight) % 10;


price = 49.99;

billingAmount = price * (1 - discount) - DECIMAL ;


// DECIMAL = 7.55;

cout << price << blanks << "$" << billingAmount << endl;

bonus = hoursWorked * PAY_RATE / 50;

cout << "Bonus = " << bonus << endl;

return 0;
}

23. A correct answer is:


#include <iostream>

using namespace std;

const char STAR = '*';


const int PRIME = 71;

10
Other documents randomly have
different content
Fig. 131.

Fig. 132.
As it is always either sunrise or sunset along the terminator, the
bright spots outside of it are clearly the tops of mountains, which
catch the rays of the sun while their bases are in the shade. The
bright patches in the neighborhood of the terminator are the sides of
hills and mountains which are receiving the full light of the sun,
while the dense shadows near by are cast by these elevations.
114. Height of the Lunar Mountains.—There are two methods of
finding the height of lunar mountains:—
(1) We may measure the length of the shadows, and then calculate
the height of the mountains that would cast such shadows with the
sun at the required height above the horizon.
The length of a shadow may be obtained by the following method: the
longitudinal wire of the micrometer (19) is adjusted so as to pass through the
shadow whose length is to be measured, and the transverse wires are placed
one at each end of the shadow, as shown in Fig. 133. The micrometer screw
is then turned till the wires are brought together, so as to ascertain the length
of the arc between them. We may then form the proportion: the number of
seconds in the semi-diameter of the moon is to the number of seconds in the
length of the shadow, as the length of the moon's radius in miles to the
length of the shadow in miles.
Fig. 133.

The height of the sun above the horizon is ascertained by measuring the
angular distance of the mountain from the terminator.

(2) We may measure the distance of a bright point from the


terminator, and then construct a right-angled triangle, as shown in
Fig. 134. A solution of this triangle will enable us to ascertain the
height of the mountain whose top is just catching the level rays of
the sun.
Fig. 134.

B is the centre of the moon, M the top of the mountain, and SAM a ray of
sunlight which just grazes the terminator at A, and then strikes the top of the
mountain at M. The triangle BAM is right-angled at A. BA is the radius of the
moon, and AM is known by measurement; BM, the hypothenuse, may then be
found by computation. BM is evidently equal to the radius of the moon plus
the height of the mountain.

By one or the other of these methods, the heights of the lunar


mountains have been found with a great degree of accuracy. It is
claimed that the heights of the lunar mountains are more accurately
known than those of the mountains on the earth. Compared with the
size of the moon, lunar mountains attain a greater height than those
on the earth.
115. General Aspect of the Lunar Surface.—A cursory examination of
the moon with a low power is sufficient to show the prevalence of
crater-like inequalities and the general tendency to circular shape
which is apparent in nearly all the surface markings; for even the
large "seas" and the smaller patches of the same character repeat in
their outlines the round form of the craters. It is along the
terminator that we see these crater-like spots to the best advantage;
as it is there that the rising or setting sun casts long shadows over
the lunar landscape, and brings elevations into bold relief. They vary
greatly in size; some being so large as to bear a sensible proportion
to the moon's diameter, while the smallest are so minute as to need
the most powerful telescopes and the finest conditions of
atmosphere to perceive them.

Fig. 135.

The prevalence of ring-shaped mountains and plains will be evident


from Fig. 135, which is from a photograph of a model of the moon
constructed by Nasmyth.
This same feature is nearly as marked in Figs. 131 and 132, which
are copies of Rutherfurd's photographs of the moon.
116. Lunar Craters.—The smaller saucer-shaped formations on the
surface of the moon are called craters. They are of all sizes, from a
mile to a hundred and fifty miles in diameter; and they are supposed
to be of volcanic origin. A high telescopic power shows that these
craters vary remarkably, not only in size, but also in structure and
arrangement. Some are considerably elevated above the surrounding
surface, others are basins hollowed out of that surface, and with low
surrounding ramparts; some are like walled plains, while the
majority have their lowest depression considerably below the
surrounding surface; some are isolated upon the plains, others are
thickly crowded together, overlapping and intruding upon each
other; some have elevated peaks or cones in their centres, and
some are without these central cones, while others, again, contain
several minute craters instead; some have their ramparts whole and
perfect, others have them broken or deformed, and many have them
divided into terraces, especially on their inner sides.
A typical lunar crater is shown in Fig. 136.
Fig. 136.

It is not generally believed that any active volcanoes exist on the


moon at the present time, though some observers have thought
they discerned indications of such volcanoes.

Fig. 137.

117. Copernicus.—This is one of the grandest of lunar craters (Fig.


137). Although its diameter (forty-six miles) is exceeded by others,
yet, taken as a whole, it forms one of the most impressive and
interesting objects of its class. Its situation, near the centre of the
lunar disk, renders all its wonderful details conspicuous, as well as
those of objects immediately surrounding it. Its vast rampart rises to
upwards of twelve thousand feet above the level of the plateau,
nearly in the centre of which stands a magnificent group of cones,
three of which attain a height of more than twenty-four hundred
feet.
Many ridges, or spurs, may be observed leading away from the outer
banks of the great rampart. Around the crater, extending to a
distance of more than a hundred miles on every side, there is a
complex network of bright streaks, which diverge in all directions.
These streaks do not appear in the figure, nor are they seen upon
the moon, except at and near the full phase. They show
conspicuously, however, by their united lustre on the full moon.
This crater is seen just to the south-west of the large dusky plain in
the upper part of Fig. 132. This plain is Mare Imbrium, and the
mountain-chain seen a little to the right of Copernicus is named the
Apennines. Copernicus is also seen in Fig. 135, a little to the left of
the same range.
Under circumstances specially favorable, myriads of comparatively
minute but perfectly formed craters may be observed for more than
seventy miles on all sides around Copernicus. The district on the
south-east side is specially rich in these thickly scattered craters,
which we have reason to suppose stand over or upon the bright
streaks.
118. Dark Chasms.—Dark cracks, or chasms, have been observed on
various parts of the moon's surface. They sometimes occur singly,
and sometimes in groups. They are often seen to radiate from some
central cone, and they appear to be of volcanic origin. They have
been called canals and rills.
Fig. 138.

One of the most remarkable groups of these chasms is that to the


west of the crater named Triesneker. The crater and the chasms are
shown in Fig. 138. Several of these great cracks obviously diverge
from a small crater near the west bank of the great one, and they
subdivide as they extend from the apparent point of divergence,
while they are crossed by others. These cracks, or chasms, are
nearly a mile broad at the widest part, and, after extending full a
hundred miles, taper away till they become invisible.
Fig. 139.

119. Mountain-Ranges.—There are comparatively few mountain-


ranges on the moon. The three most conspicuous are those which
partially enclose Mare Imbrium; namely, the Apennines on the south,
and the Caucasus and the Alps on the east and north-east. The
Apennines are the most extended of these, having a length of about
four hundred and fifty miles. They rise gradually, from a
comparatively level surface towards the south-west, in the form of
innumerable small elevations, which increase in number and height
towards the north-east, where they culminate in a range of peaks
whose altitude and rugged aspect must form one of the most terribly
grand and romantic scenes which imagination can conceive. The
north-east face of the range terminates abruptly in an almost vertical
precipice; while over the plain beneath, intensely black spire-like
shadows are cast, some of which at sunrise extend full ninety miles,
till they lose themselves in the general shading due to the curvature
of the lunar surface. Many of the peaks rise to heights of from
eighteen thousand to twenty thousand feet above the plain at their
north-east base (Fig. 139).

Fig. 140.

Fig. 140 represents an ideal lunar landscape near the base of such a
lunar range. Owing to the absence of an atmosphere, the stars will
be visible in full daylight.
Fig. 141.

120. The Valley of the Alps.—The range of the Alps is shown in Fig.
141. The great crater at the north end of this range is named Plato.
It is seventy miles in diameter.
The most remarkable feature of the Alps is the valley near the centre
of the range. It is more than seventy-five miles long, and about six
miles wide at the broadest part. When examined under favorable
circumstances, with a high magnifying power, it is seen to be a vast
flat-bottomed valley, bordered by gigantic mountains, some of which
attain heights of ten thousand feet or more.

Fig. 142.

121. Isolated Peaks.—There are comparatively few isolated peaks to


be found on the surface of the moon. One of the most remarkable of
these is that known as Pico, and shown in Fig. 142. Its height
exceeds eight thousand feet, and it is about three times as long at
the base as it is broad. The summit is cleft into three peaks, as is
shown by the three-peaked shadow it casts on the plain.
122. Bright Rays.—About the time of full moon, with a telescope of
moderate power, a number of bright lines may be seen radiating
from several of the lunar craters, extending often to the distance of
hundreds of miles. These streaks do not arise from any perceptible
difference of level of the surface, they have no very definite outline,
and they do not present any sloping sides to catch more sunlight,
and thus shine brighter, than the general surface. Indeed, one great
peculiarity of them is, that they come out most forcibly when the sun
is shining perpendicularly upon them: hence they are best seen
when the moon is at full, and they are not visible at all at those
regions upon which the sun is rising or setting. They are not diverted
by elevations in their path, but traverse in their course craters,
mountains, and plains alike, giving a slight additional brightness to
all objects over which they pass, but producing no other effect upon
them. "They look as if, after the whole surface of the moon had
assumed its final configuration, a vast brush charged with a whitish
pigment had been drawn over the globe in straight lines, radiating
from a central point, leaving its trail upon every thing it touched, but
obscuring nothing."
Fig. 143.

The three most conspicuous craters from which these lines radiate
are Tycho, Copernicus, and Kepler. Tycho is seen at the bottom of
Figs. 143 and 130. Kepler is a little to the left of Copernicus in the
same figures.
It has been thought that these bright streaks are chasms which have
been filled with molten lava, which, on cooling, would afford a
smooth reflecting surface on the top.
123. Tycho.—This crater is fifty-four miles in diameter, and about
sixteen thousand feet deep, from the highest ridge of the rampart to
the surface of the plateau, whence rises a central cone five thousand
feet high. It is one of the most conspicuous of all the lunar craters;
not so much on account of its dimensions as from its being the
centre from whence diverge those remarkable bright streaks, many
of which may be traced over a thousand miles of the moon's surface
(Fig. 143). Tycho appears to be an instance of a vast disruptive
action which rent the solid crust of the moon into radiating fissures,
which were subsequently filled with molten matter, whose superior
luminosity marks the course of the cracks in all directions from the
crater as their common centre. So numerous are these bright streaks
when examined by the aid of the telescope, and they give to this
region of the moon's surface such increased luminosity, that, when
viewed as a whole, the locality can be distinctly seen at full moon by
the unassisted eye, as a bright patch of light on the southern portion
of the disk.
III. INFERIOR AND SUPERIOR PLANETS.

Inferior Planets.

124. The Inferior Planets.—The inferior planets are those which lie
between the earth and the sun, and whose orbits are included by
that of the earth. They are Mercury and Venus.

Fig. 144.

125. Aspects of an Inferior Planet.—The four chief aspects of an


inferior planet as seen from the earth are shown in Fig. 144, in
which S represents the sun, P the planet, and E the earth.
When the planet is between the earth and the sun, as at P, it is said
to be in inferior conjunction.
When it is in the same direction as the sun, but beyond it, as at P'',
it is said to be in superior conjunction.
When the planet is at such a point in its orbit that a line drawn from
the earth to it would be tangent to the orbit, as at P' and P''', it is
said to be at its greatest elongation.

Fig. 145.

126. Apparent Motion of an Inferior Planet.—When the planet is at


P, if it could be seen at all, it would appear in the heavens at A. As it
moves from P to P', it will appear to move in the heavens from A to
B. Then, as it moves from P' to P'', it will appear to move back again
from B to A. While it moves from P'' to P''', it will appear to move
from A to C; and, while moving from P''' to P, it will appear to move
back again from C to A. Thus the planet will appear to oscillate to
and fro across the sun from B to C, never getting farther from the
sun than B on the west, or C on the east: hence, when at these
points, it is said to be at its greatest western and eastern
elongations. This oscillating motion of an inferior planet across the
sun, combined with the sun's motion among the stars, causes the
planet to describe a path among the stars similar to that shown in
Fig. 145.

Fig. 146.
127. Phases of an Inferior Planet.—An inferior planet, when viewed
with a telescope, is found to present a succession of phases similar
to those of the moon. The reason of this is evident from Fig. 146. As
an inferior planet passes around the sun, it presents sometimes
more and sometimes less of its bright hemisphere to the earth.
When the earth is at T, and Venus at superior conjunction, the
planet turns the whole of its bright hemisphere towards the earth,
and appears full; it then becomes gibbous, half, and crescent. When
it comes into inferior conjunction, it turns its dark hemisphere
towards the earth: it then becomes crescent, half, gibbous, and full
again.
128. The Sidereal and Synodical Periods of an Inferior Planet.—The
time it takes a planet to make a complete revolution around the sun
is called the sidereal period of the planet; and the time it takes it to
pass from one aspect around to the same aspect again, its synodical
period.
Fig. 147.

The synodical period of an inferior planet is longer than its sidereal


period. This will be evident from an examination of Fig. 147. S is the
position of the sun, E that of the earth, and P that of the planet at
inferior conjunction. Before the planet can be in inferior conjunction
again, it must pass entirely around its orbit, and overtake the earth,
which has in the mean time passed on in its orbit to E'.
While the earth is passing from E to E', the planet passes entirely
around its orbit, and from P to P' in addition. Now the arc PP' is just
equal to the arc EE': hence the planet has to pass over the same arc
that the earth does, and 360° more. In other words, the planet has
to gain 360° on the earth.
The synodical period of the planet is found by direct observation.
129. The Length of the Sidereal Period.—The length of the sidereal period of
an inferior planet may be found by the following computation:—

Let a denote the synodical period of the planet,


Let b denote the sidereal period of the earth,
Let x denote the sidereal period of the planet.
Then 360°/b = the daily motion of the earth,
And 360°/x = the daily motion of the planet,
And 360°/x - 360°/b = the daily gain of the planet:
Also 360°/a = the daily gain of the planet:
Hence 360°/x - 360°/b = 360°/a.
Dividing by 360°, we have 1/x - 1/b = 1/a;
Clearing of fractions, we have ab - ax = bx:
Transposing and collecting, we have (a + b)x = ab:

Therefore x = ab/a+b.

130. The Relative Distance of an Inferior Planet.—By the relative


distance of a planet, we mean its distance from the sun
compared with the earth's distance from the sun. The relative
distance of an inferior planet may be found by the following
method:—
Fig. 148.
Let V, in Fig. 148, represent the position of Venus at its greatest elongation
from the sun, S the position of the sun, and E that of the earth. The line EV
will evidently be tangent to a circle described about the sun with a radius
equal to the distance of Venus from the sun at the time of this greatest
elongation. Draw the radius SV and the line SE. Since SV is a radius, the angle
at V is a right angle. The angle at E is known by measurement, and the angle
at S is equal to 90°- the angle E. In the right-angled triangle EVS, we then
know the three angles, and we wish to find the ratio of the side SV to the side
SE.
The ratio of these lines may be found by trigonometrical computation as
follows:—

VS : ES = sin SEV : 1.

Substitute the value of the sine of SEV, and we have


VS : ES = .723 : 1.

Hence the relative distances of Venus and of the earth from the
sun are .723 and 1.

Superior Planets.

131. The Superior Planets.—The superior planets are those which lie
beyond the earth. They are Mars, the Asteroids, Jupiter, Saturn,
Uranus, and Neptune.
Fig. 149.

132. Apparent Motion of a Superior Planet.—In order to deduce the


apparent motion of a superior planet from the real motions of the
earth and planet, let S (Fig. 149) be the place of the sun; 1, 2, 3,
etc., the orbit of the earth; a, b, c, etc., the orbit of Mars; and CGL a
part of the starry firmament. Let the orbit of the earth be divided
into twelve equal parts, each described in one month; and let ab, bc,
cd, etc., be the spaces described by Mars in the same time. Suppose
the earth to be at the point 1 when Mars is at the point a, Mars will
then appear in the heavens in the direction of 1 a. When the earth is
at 3, and Mars at c, he will appear in the heavens at C. When the
earth arrives at 4, Mars will arrive at d, and will appear in the
heavens at D. While the earth moves from 4 to 5 and from 5 to 6,
Mars will appear to have advanced among the stars from D to E and
from E to F, in the direction from west to east. During the motion of
the earth from 6 to 7 and from 7 to 8, Mars will appear to go
backward from F to G and from G to H, in the direction from east to
west. During the motion of the earth from 8 to 9 and from 9 to 10,
Mars will appear to advance from H to I and from I to K, in the
direction from west to east, and the motion will continue in the same
direction until near the succeeding opposition.
The apparent motion of a superior planet projected on the heavens
is thus seen to be similar to that of an inferior planet, except that, in
the latter case, the retrogression takes place near inferior
conjunction, and in the former it takes place near opposition.

Fig. 150.

133. Aspects of a Superior Planet.—The four aspects of a superior


planet are shown in Fig. 150, in which S is the position of the sun, E
that of the earth, and P that of the planet.
When the planet is on the opposite side of the earth to the sun, as
at P, it is said to be in opposition. The sun and the planet will then
appear in opposite parts of the heavens, the sun appearing at C, and
the planet at A.
When the planet is on the opposite side of the sun to the earth, as
at P'', it is said to be in superior conjunction. It will then appear in
the same part of the heavens as the sun, both appearing at C.
When the planet is at P' and P''', so that a line drawn from the earth
through the planet will make a right angle with a line drawn from
the earth to the sun, it is said to be in quadrature. At P' it is in its
western quadrature, and at P''' in its eastern quadrature.

Fig. 151.

134. Phases of a Superior Planet.—Mars is the only one of the


superior planets that has appreciable phases. At quadrature, as will
appear from Fig. 151, Mars does not present quite the same side to
the earth as to the sun: hence, near these parts of its orbit, the
planet appears slightly gibbous. Elsewhere in its orbit, the planet
appears full.
All the other superior planets are so far away from the sun and
earth, that the sides which they turn towards the sun and the earth
in every part of their orbit are so nearly the same, that no change in
the form of their disks can be detected.
135. The Synodical Period of a Superior Planet.—During a synodical
period of a superior planet the earth must gain one revolution, or
360°, on the planet, as will be evident from an examination of Fig.
152, in which S represents the sun, E the earth, and P the planet at
opposition. Before the planet can be in opposition again, the earth
must make a complete revolution, and overtake the planet, which
has in the mean time passed on from P to P'.

Fig. 152.

In the case of most of the superior planets the synodical period is


shorter than the sidereal period; but in the case of Mars it is longer,
since Mars makes more than a complete revolution before the earth
overtakes it.
The synodical period of a superior planet is found by direct
observation.
136. The Sidereal Period of a Superior Planet.—The sidereal period of a
superior planet is found by a method of computation similar to that for finding
the sidereal period of an inferior planet:—

Let a denote the synodical period of the planet,


Let b denote the sidereal period of the earth,
Let x denote the sidereal period of the planet.
Then will 360°/b = daily motion of the earth,
And 360°/x = daily motion of the planet;
Also 360°/b - 360°/x = daily gain of the earth.
But 360°/a = daily gain of the earth:
Hence 360°/b - 360°/x = 360°/a

1/b - 1/x = 1/a

ax - ab = bx

(a-b)x = ab

x = ab/(a-b).

Fig. 153.

137. The Relative Distance of a Superior Planet.—Let S, e, and m, in Fig. 153,


represent the relative positions of the sun, the earth, and Mars, when the
latter planet is in opposition. Let E and M represent the relative positions of

You might also like