Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Solution manual for C++ Programming From Problem Analysis to Program Design 6th Edition by D.S. Malik

Rating
-
Sold
-
Pages
21
Grade
A+
Uploaded on
28-01-2022
Written in
2021/2022

QUESTIONS 1. a. false; b. false; c. true; d. false; e. false; f; false; g. false; h. true; i. true; j. false; k. true; l. false 2. The basic commands that a computer performs are input (get data), output (display result), storage, and performance of arithmetic and logical operations 3. Central processing unit (CPU), main memory (MM), and input/output devices. 4. Secondary storage permanently stores programs and data. 5. An operating system monitors the overall activity of the computer and provides services. Some of these services include memory management, input/output activities, and storage management. 6. The two types of programs are system programs and application programs. 7. In machine language the programs are written using the binary codes while in high-level language the program are closer to the natural language. For execution, a high-level language program is translated into the machine language while a machine language need not be translated into any other language. 8. A program written in a high-level language is called a source program. 9. Because the computer cannot directly execute instructions written in a high-level language, a compiler is needed to translate a program written in high-level language into machine code. 10. A compiler reports syntax errors. ANSWERS 1. a. false; b. false; c. false; d. true; e. true; f. false; g. true; h. true; i. false; j. true; k. false 2. a, b, d, e, j 3. b, d, 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 firstName and FirstName are not the same. C++ is case sensitive. The first letter of firstName is lowercase f while the first character of FirstName is uppercase F. So these identifiers are different 6 a. 7 b. 3 c. 3 d. -2 e. 4.4 f. 25.5 g. 26 h. 21.75 7. a. 3 b. Not possible. Both the operands of the operator % must be integers. Because the second operand, w, is a floating-point value, the expression is invalid. c. Not possible. Both the operands of the operator % must be integers. Because the first operand, which is y + w, is a floating-point value, the expression is invalid . d. 38.5 e. 1 f. 2 g. 2 h. 420.0 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. 7 10. Variable declarations in Lines 2, 4, 5 and 6 are correct. Variable declaration in Line 1 is incorrect because the left side of the assignment operator must be a variable, and the data type of the variable must be specified. A correct declaration is: int age = 55; //Line 1 The variable declaration in Line 3 is incorrect because strings are enclosed in double quotation marks, and the semicolon at the end of the statement is missing. string message = "First test is on Monday"; //Line 3 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_castint(z + 0.5); 13. a. 32 * a + b b. '8' c. "Julie Nelson" d. (b * b – 4 * a * c) / (2 * a) e. (a + b) / c * (e * f) – g * h f. (–b + (b * b – 4 * a * c)) / (2 * a) 14. x = 6 y = 29 z = 3 w = -10 15. x = 28 y = 35 z = 1 w = 22.00 t = 6.5 16. a. x = 2, y = 5, z = 6 b. x + y = 7 c. Sum of 2 and 6 is 8 d. z / x = 3 e. 2 times 2 = 4 17. a. 0.50 b. 24.50 c. 37.6 d. 8.3 e. 10 f. 38.75 18. a. cout endl; or cout "n"; or cout 'n'; b. cout "t"; c. cout """; 19. a and c are correct 20. a. firstName b. discountedPrice c. numOfJuiceBottles d. milesTravelled e. highestTestScore

Show more Read less
Institution
Course

Content preview

1

,QUESTIONS
1. a. false; b. false; c. true; d. false; e. false; f; false; g. false; h. true; i. true; j. false; k. true; l. false
2. The basic commands that a computer performs are input (get data), output (display result), storage, and
performance of arithmetic and logical operations
3. Central processing unit (CPU), main memory (MM), and input/output devices.
4. Secondary storage permanently stores programs and data.
5. An operating system monitors the overall activity of the computer and provides services. Some of
these services include memory management, input/output activities, and storage management.
6. The two types of programs are system programs and application programs.
7. In machine language the programs are written using the binary codes while in high-level language the
program are closer to the natural language. For execution, a high-level language program is translated
into the machine language while a machine language need not be translated into any other language.
8. A program written in a high-level language is called a source program.
9. Because the computer cannot directly execute instructions written in a high-level language, a compiler
is needed to translate a program written in high-level language into machine code.
10. A compiler reports syntax errors.
11. Every computer directly understands its own machine language. Therefore, for the computer to execute
a program written in a high-level language, the high-level language program must be translated into the
computer’s machine language.
12. Instructions in a high-level language are closer to a natural language, such as English, and therefore are
easier to understand and learn than machine language.
13. In linking an object program is combined with other programs in the library, used in the program, to
create the executable code.
14. A well-analyzed problem leads to a well-designed algorithm. Moreover, a program that is well
analyzed is easier to modify as well as spot and fix errors.
15. To find the weighted average of the four test scores, first you need to know each test score and its
weight. Next, you multiply each test score with its weight, and then add these numbers to get the
average. Therefore,
1. Get testScore1, weightTestScore1
2. Get testScore2, weightTestScore2
3. Get testScore3, weightTestScore3
4. Get testScore4, weightTestScore4
5. weightedAverage = testScore1 * weightTestScore1 +
testScore2 * weightTestScore2 +
testScore3 * weightTestScore3 +
testScore4 * weightTestScore4;
16. a. Get quarters
b. Get dimes
c. Get nickels
d. Get pennies




2

, e. changeInPennies = quarters * 25 + dimes * 10 + nickels * 5
+ pennies
17. To find the price per square inch, first we need to find the area of the pizza. Then we divide the price
of the pizza by the area of the pizza. Let radius denote the radius and area denote the area of the
circle, and price denote the price of pizza. Also, let pricePerSquareInch denote the price per
square inch.
a. Get radius
b. area = π * radius * radius
c. Get price
d. pricePerSquareInch = price / area
18. To calculate the selling price of an item, we need to know the original price (the price the store pays to
buy) of the item. We can then the use the following formula to find the selling price:
sellingPrice = (originalPrice + originalPrice × 0.80) × 0.90
The algorithm is as follows:
a. Get originalPrice
b. Calculate the sellingPrice using the formula:
sellingPrice = (originalPrice + originalPrice × 0.80) × 0.90
The information needed to calculate the selling price is the original price and the marked-up
percentage.
19. To calculate the area of a triangle using the given formula, we need to know the lengths of the
sides―a, b, and c―of the triangle. Next, we calculate s using the formula:
s = (1/2)(a + b + c)
and then calculate the area using the formula:
area = sqrt(s(s-a)(s-b)(s-c))
where sqrt denotes the square root.
The algorithm, therefore, is:
a. Get a, b, c
b. s = (1/2)(a + b + c)
c. area = sqrt(s(s-a)(s-b)(s-c))
The information needed to calculate the area of the triangle is the lengths of the sides of the triangle.
20. Suppose that billingAmount denotes the total billing amount, numOfItemsOrdered denotes the
number of items ordered, shippingAndHandlingFee denotes the shipping and handling fee, and
price denotes the price of an item. The following algorithm computes and outputs the billing
amount.
a. Enter the number of items bought.
b. Get numOfItemsOrdered
c. billingAmount = 0.0;
d. shippingAndHandlingFee = 0.0;
e. Repeat the following for each item bought.



3

Connected book

Written for

Institution
Course

Document information

Uploaded on
January 28, 2022
Number of pages
21
Written in
2021/2022
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$4.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
brightergrades Howard University
Follow You need to be logged in order to follow users or courses
Sold
208
Member since
4 year
Number of followers
192
Documents
0
Last sold
3 days ago

2.6

23 reviews

5
6
4
3
3
1
2
1
1
12

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions