Engineering problem solving with C 4th edition. Debora Panda. COMMON C FUNCTIONS Elementary Math Functions (Text page 66) ceil(x) exp(x) fabs(x). Full file at peypredkoefritlec.ml Edition-Etter-Solutions-Manual Exam Practice! 1. T 2. F 3. T 4. T 5. F 6. Not Correct. Engineering Problem Solving with C. Pages · Thinking Skills: Critical Thinking and Problem Solving. Pages·· 4th ed Data Str.
|Language:||English, Spanish, French|
|Genre:||Children & Youth|
|Distribution:||Free* [*Registration needed]|
Engineering Problem Solving With C++, Fourth Edition provides a clear, concise introduction to engineering problem solving with C++ as well. Engineering Problem Solving with C, 4th Edition. Delores M. Etter, Southern Methodist University. © |Pearson | Out of print. Share this page. Engineering . ENGINEERING. PROBLEM SOLVING. WITH C++. Third Edition. Delores M. Etter. Electrical Engineering Department. Southern Methodist University, Dallas, TX.
Number Systems The base 10 number system has 10 decimal digits, 09 and each digit in a decimal number multiplies a power of Most of us have an easy time counting in base 10 and comprehending base 10 numbers. When we read the number for example, we read it as two hundred and fourtyve. We understand that the 2 is in the hundreds position , the 4 in the tens position and the 5 in the ones position If we expand the number as follows: In the following sections, we will discuss three number systems, binary, octal and hexadecimal, that are useful when studying digital computer systems.
We will also develop algorithms for converting numbers to different bases. Binary Numbers. Digital computers represent data in binary form. The base two number system has two binary digits, 0 and 1, and each digit multiplies a power of 2.
If we examine the binary number, , stored in memory location in Figure 1. Suppose that we have a decimal number that we wish to represent in base 2. The equivalent binary number will be a sequence of binary digits. To generate these digits, we will use a conversion algorithm that repeatedly divides the decimal number by 2, and records the remainder of each division as a successive digit of the equivalent binary number.
We illustrate the use of the algorithm in the example below. Note that the remainder of the rst division is recorded as the least signicant digit LSD of the equivalent binary number, the remainder of the last division is recorded as the most signicant digit MSD , and we divide until the quotient becomes zero.
The base of the other number system denes the divisor, as we will see in the following sections. Octal Numbers. The octal, or base 8, number system has 8 octal digits, For example, if we have a le that we want to be readable, writable, and executable by everyone, we can use the chmod command to set the permissions on the le as follows: If we next do a long listing, ls -l we will see something like the following: The above indicates that r ead w rite x execute permission is granted to the owner, the group and the world.
If we wish to grant only read status to the group and the world, we can change the permissions with the following command: Each digit in an octal number multiplies a power of 8.
To determine the equivalent decimal value of an octal number, we can apply the same conversion algorithm used to determine the decimal value of a binary number. Note that the base of the number being converted to decimal, 8 in this case, denes the base of the exponential terms. We apply the algorithm using 8 as our divisor. One approach would be to rst convert the base 8 number to base 10, and then convert the equivalent base 10 number to base 8.
Table 1. TABLE 1. Convert each of the following base 10 numbers to base 2. Hexadecimal Numbers. The hexadecimal, or base 16, number system has 16 hexadecimal digits, 09,AF , and each digit in a hexadecimal number multiplies a power of The decimal values of the hexadecimal digits represented by letters are 10,11,12,13,14,15 respectively.
The number 2BF16 is an example of a hexadecimal number. Applying the conversion algorithm for converting from any base to base 10, we can determine the equivalent decimal number, as illustrated below.
The remainder of each division is a value between 0 and F. This relationship can be used to quickly convert from binary to hexadecimal and hexadecimal to binary, as illustrated in the next two examples. Convert each of the following base 10 numbers to base When data is represented in memory, it is represented as a sequence of bits.
The sequence of bits may represent an instruction, a numeric value, a character, a portion of an image or digital signal, or some other type of data. If we look at the bit sequence , for example, it has a decimal value of Data representation is becoming an increasingly important and interesting eld in engineering, math and computer science.
The amount of data that can be generated and processed is increasing as computers become more powerful, and the use of computers in data intensive applications such as bio-computing, communications and signal processing present new challenges for dening and representing data.
In this section, we will discuss the digital representation of two basic data types, integer and oating point. Integer Data Type. In the previous section, we used an algorithm to convert from base 10 to base 2. This algorithm works for any base 10 integer, so in theory we can represent, exactly, all base 10 integers in base 2. In practice, we may be limited by the word size of our computing system.
Integer data is often stored in memory using 4 bytes, or 32 bits. The left most bit is reserved for the sign, leaving 31 bits for the magnitude of the number. Consider the following example that uses a word size of 8 for simplicity.
The largest signed integer that can be represented in 8 bits is 27 1 or , as illustrated below. The representation of data in a digital computer affects the efciency of arithmetic and logic operations.
Many computer systems store positive signed integers as illustrated above, and store negative signed integers in their 2s complement form. Storing negative integers in their 2s complement form allows for efcient execution of arithmetic operations, without checking the sign bit. First, we illustrate how to form the 2s complement of a negative number, then we will illustrate how storing negative numbers in their 2s complement form can simplify arithmetic operations.
The 2s complement of a binary number is formed by negating all of the bits and adding one. Negating a bit means switching the value, or state, of a bit from 1 to 0, or from 0 to 1. Negating all the bits of a binary number forms the 1s complement of the number. Adding one to the 1s complement results in the 2s complement of the number. Using a word size of 8, the 2s complement of is computed in the following example. Example Compute the 2s complement representation for the value To form the 2s complement of a negative integer, we begin with the binary representation of the unsigned value.
Next, we negate the bits to form the 1s complements. Thus, the 2s complement representation for is Notice what happens when we add to the 2s complement of The 2s complement form for representing signed integers has the property that adding a positive integer, n, to the 2s complement of n results in zero for all n. Another important property of 2s complement representation is that there is a unique representation for binary 0. When performing addition on signed integers represented in 2s complement form, the result, if negative, will be in its 2s complement form, as shown in the following examples.
Addition of 2 binary numbers, positive result. Find the 2s complement of the following integers: Floating Point Data Type. A oating point number, or real number, such as The digits to the left of the decimal point form the integral part of the number and the digits to the right of the decimal point form the fractional part of a number.
The fractional part of a decimal number can be converted to binary by repeatedly multiplying the factional part by 2 and recording the carry bits until the factional part becomes zero. This algorithm is illustrated in the following example.
Thus, the value To convert the oating point binary number Unfortunately, many oating points decimal have only an approximate binary representation, as illustrated in the next example. The integral portion, has been shown to equal Converting the fractional portion, we repeatedly multiply by 2 and record the carry bits.
We can see that we are repeating the bit pattern of and will never arrive at a terminating value of zero. Thus, the best binary approximation of 0. Expanding this to 8 bits of precision, we have:. It is important to know that the binary representation of a oating point decimal is an approximation, not an equality. This affects the way we use and test oating point values in programs and it also affects the accuracy of numerical calculations.
Therefore, it is important to have a consistent approach to solving problems. It is also helpful if the approach is general enough to work for all these different areas so that we do not have to learn one technique for mathematics problems, a different technique for physics problems, and so on.
The problem-solving process that we present works for engineering problems and can be tailored to solve problems in other areas as well; however, it does assume that we are using the computer to help solve the problem.
The process or methodology for problem solving that we will use throughout this text has ve steps: Describe the input and output information of the problem. Work the problem by hand or with a calculator for a simple set of data. Develop a solution and convert it to a computer program. We now discuss each of these steps using an example of computing the distance between two points in a plane.
It is extremely important to give a clear, concise problem statement to avoid any misunderstandings. For this example, the problem statement is the following: Compute the straight-line distance between two points in a plane.
For many problems, a diagram that shows the input and output is useful. At this point, the program is an abstraction because we are not dening the steps to determine the output; instead, we are only showing the information that is required to compute the desired output.
This is a very important step and should not be skipped even for simple problems. This is the step in which you work out the details of the problem solution. If you cannot take a simple set of numbers and compute the output either by hand or with a calculator , then you are not ready to move on to the next step; you should reread the problem, and perhaps consult reference material. The solution by hand for this specic example follows: Let the points p1 and p2 have the following coordinates: Using the Pythagorean theorem, we can compute the distance with the following equation: For simple problems such as this one, the algorithm can be listed as operations that are performed one after another.
This outline of steps decomposes the problem into simpler steps, as shown by the following outline of the steps required to compute and print the distance between two points. Decomposition Outline 1. Give values to the two points. Compute the lengths of the two sides of the right triangle generated by the two points. Compute the distance between the two points, which is equal to the length of the hypotenuse of the triangle.
Print the distance between the two points. From the following solution, you can see that the commands are very similar to the steps used in the hand example. The details of these commands are explained in Chapter 2.
We should rst test the solution with the data from the hand example because we have already computed the solution. The distance between the points is 3. Once the solution works for the hand example, we should also test it with additional sets of data to be sure that the solution works for other valid sets of data. The set of steps demonstrated in this example are used in developing the programs in the Problem Solving Applied sections in the chapters that follow.
A brief history of the development of the digital computer was provided, followed by a group of outstanding recent engineering achievements to demonstrate the diversity of engineering applications, and the impact of computers in engineering. We also discussed some of the nontechnical skills required to be a successful engineer.
Because the solutions to most engineering problems will be by computer, we presented a summary of the components of a computer system, from computer hardware to computer software and the importance of learning the new terminology. We also discussed number systems and data representation and introduced. These ve steps are as follows: Describe the input and output information for the problem.
This process will be used throughout the text as we develop solutions to problems. Problems Exam Practice! Linking and loading is the step that prepares the object program for execution. An algorithm describes the problem solution step by step, while a computer program solves the problem in one step. A computer program is the implementation of an algorithm. Multiple-Choice Problems Circle the letter for the best answer to complete each statement, or for the correct answer to each question.
Instructions and data are stored in a the arithmetic logic unit ALU. An operating system is a the software that is designed by users. Source code is a the result of compiler operations. An algorithm refers to a a step-by-step solution to solve a specic problem. Object code is a the result of compiler operations on the source code. Convert the following binary numbers to octal. Convert the following binary numbers to hexadecimal. Convert the following decimal numbers to octal. Convert the following numbers to base Perhaps your professor will even select some of the written reports for oral presentation in class.
Each report should include at least two references, so you will want to learn how to use library computers to locate reference information. Prepare your report using word-processor software. If you do not already know how to use a word processor, ask your professor for guidance or visit your universitys Web site for links to resources on campus.
Write a short report on one of these outstanding engineering achievements: Write a short report on one of these engineering challenges: Predication of weather, climate, and global change Computerized speech understanding Mapping of the human genome Improved vehicle performance A good starting point for nding references is the NASA Web site: Write a short report on an outstanding engineering achievement that is not included in the list given in this chapter.
Past issues of Scientic American and the Web would provide some good ideas of recent achievements. Vehicle Performance Turboprop engines combine the power and reliability of jet engines with the efciency of propellers.
Turboprops use a gas turbine to turn a propeller. Their application has been limited to smaller aircraft because turboprop engines are most efcient at ight speeds under mph. However, the engineering of new materials, blade shapes, and propellers continues to increase the speed and efciency of the turboprop and the demand for the engine.
The program that follows was rst introduced in Chapter 1; it computes and prints the distance between two points. We now briey discuss the statements in this specic example; each of the statements is discussed in detail in later sections of this chapter. Although comments are optional, good style requires that comments be used throughout a program to improve its readability and to document the computations. In the text programs, we always use initial comments to give a name to the program and to describe the general purpose of the program; additional explanation comments are also included throughout the program.
Preprocessor directives give instructions to the preprocessor that are performed before the program is compiled. The most common directive inserts additional statements in the program; it contains the characters include followed by the name of the le containing the additional statements. This program contains the following two preprocessor directives: These directives specify that statements in the les iostream and cmath should be included in place of these two statements before the program is compiled.
The le iostream contains information related to the output statement used in this program, and the le cmath contains information related to the function used in this program to compute the square root of a value. Preprocessor directives are generally included after the initial comments describing the programs purpose. The next statement using namespace std;. The using directive tells the compiler to use the library lenames declared in namespace std.
Some older compilers do not support namespaces. If your compiler does not accept the using namespace statement then you will need to omit the using namespace std; statement and change the name of the les used in the preprocessor directives to the following: Older compiles use a. You will see the le math. The keyword int indicates that the function returns an integer value to the operating system.
The parentheses following main are required because main is a function. In order to easily identify the block of code that denes body of the function, we place the braces on lines by themselves. Thus, the two lines following the preprocessor directives specify the beginning of the main function: The main function contains two types of commands: The declarations dene identiers and allocate memory and therefore must precede any statements that reference these identiers.
The declarations may or may not give initial values to be stored. A comment precedes the declaration statement in the following program: These declarations specify that the program will use seven objects named x1, y1, x2, y2, side1, side2, and distance.
Each object will store a double-precision oating-point value; these objects can store noninteger values such as In addition, this statement species that x1 should be initialized given an initial value to the value 1, y1 should be initialized to the value 5, x2 should be initialized to the value 4, and y2 should be initialized the value 7. The initial values of side1, side2, and distance are not specied and should not be assumed to be initialized to zero.
Because the declaration was too long for one line, we split it over two lines; the indenting of the second line indicates that it is a continuation of the previous line. The indenting is a matter of style and readability; it is not required. The semicolon ends the declaration statement. The statements that specify the operations to be performed in the example program are the following: These statements compute the lengths of the two sides of the right triangle formed by two points see Figure 1.
The details of the syntax of these assignment statements are discussed later in the chapter. After the distance is computed, it is printed with the cout statement. This output statement is too long for a single line, so we separate the statement into two lines; the indenting of the second line again indicates that it is a continuation of the previous line.
A semicolon ends the output statement. Additional comments were used to explain the computations and the output statement. To end execution of the program and return control to the operating system, we use a return 0 ; statement. This statement returns a value of zero to the operating system. A value of zero indicates a successful end of execution. The body of the main function then ends with the right brace on a line by itself, and another comment line to delineate the end of the main function.
Note that we have included blank lines also called whitespace in the program to separate different components. These blank lines make a program more readable and easier to modify. The statements within the main function were indented in order to show the structure of the program. This spacing provides a consistent style, and makes our programs easier to read. This structure is evident in the programs developed in this chapter and in the chapters that follow.
Then compile and execute the program. You should get this output: The distance between the two points is. Change the values given to the two points to the coordinates 1, 6 and 2, 4.
Run the program with these new values. Did the distance change? Change the values given to the two points so that they represent the coordinates 1, 0 and 5, 7. Check the programs answer with your calculator. Change the values given to the two points so that they represent the same coordinates 2, 4 and 2, 4. Does the program give the correct answer? Constants and variables represent objects that we use in our programs. Literal constants are specic values such as 2, 3.
The value of these objects cannot be changed. Variables are memory locations that are assigned a name or identier. The identier is used to reference the value stored in the memory location. A useful analogy for a memory location and its corresponding identier is a mailbox that is associated with the name of an individual; the memory location or mailbox may contain an If.
The values of variables that were not given initial values are unspecied, and thus indicated with a question mark; sometimes these values are called garbage values because their values are unpredictable. A diagram such as this that shows an object along with its identier, its value, and its data type is called a memory snapshot. A memory snapshot shows the contents of a memory location at a specied point in the execution of the program.
The preceding memory snapshot shows the objects and their contents after execution of the declaration statement. The objects are declared to be of type double and will be represented in memory using the standard IEEE format.
For simplicity we show only the value of the variable and its data type, but it is important to remember that the value of a oating point variable, even when initialized with an integer constant, will be represented in memory using the IEEE oating point representation of the integer value. We frequently use memory snapshots to show the contents of objects both before and after a statement is executed in order to show its effect.
The rules for selecting a valid identier are as follows:. Examples of valid identiers are distance, x1, xSum, averageMeasurement, and initialTime. An identier name should be carefully selected so that it reects the contents of the object. If possible, the name should also indicate the units of measurement. For example, if an object represents a temperature measurement in degrees Fahrenheit, use an identier such as tempF or degreesF. If an object represents an angle, name it thetaRad to indicate that the angle is measured in radians or thetaDeg to indicate that the angle is measured in degrees.
Declarations statements included in any block of code must include not only the identiers of the objects that we plan to use in our program, but they must also specify the data type of the object.
This means that every. Data types are presented after a discussion on scientic notation. Determine which of the following names are valid identiers. If a name is not a valid identier, give the reason that it is not acceptable, and suggest a valid replacement. A oating-point value is one that can represent both integer and non-integer values, such as 2.
A oating-point value expressed in scientic notation is rewritten as a mantissa times a power of 10, where the mantissa has an absolute value greater than or equal to 1. For example, in scientic notation, In exponential notation, the letter e is used to separate the mantissa from the exponent of the power of Thus, in exponential notation, The number of digits allowed by the computer for the decimal portion of the mantissa determines the precision, and the number of digits allowed for the exponent determines the range.
Thus, values with two digits of precision and an exponent range of 8 to 7 could include values such as 2. This precision and exponent range would not be sufcient for many of the types of values that we use in engineering problem solutions.
For example, the distance in mile from Mars to the Sun, with seven digits of precision, is ,,, or 1. In problems 1 through 6, express the value in scientic notation. Specify the number of digits of precision needed to represent each value. In problems 7 through 12, express the value in oating-point notation. Numeric Data Types Numeric data types are used to specify the types of numbers that will be contained in objects.
The following diagram shows the built-in numeric data types and their speciers that are discussed in the next few paragraphs: The type speciers for signed integers are short, int, and long, for short integer, integer, and long integer, respectively. The specic ranges of values are system dependent, which means that the ranges can vary from one system to another. In the last section of this chapter, we present a program that you can use to determine the ranges of the numeric data types on your system.
On many systems, the short integer data type range from 32, to 32,, and the integer and long integer type often represents values from 2,,, to 2,,, The unusual limits such as 32, and 2,,, relate to conversions of binary values to decimal values. An unsigned integer can represent only positive values. Signed and unsigned integers can represent the same number of values, but the ranges are different. For example, if an unsigned short has the range of values from 0 to 65,, then a short integer has the range of values from 32, to 32,; both data types can represent a total of 65, values.
A type declaration statement denes new identifers and allocates memory. An initial value may be assigned to the memory location at the time the identier is dened. Modiers may also be specied. The difference between the float, double, and long double types relates to the precision or accuracy and the range of the values represented.
The precision and range are system dependent. Table 2. A program given in Section 2. On most systems, a double data type stores about twice as many decimal digits of precision as are stored with a float data type. In addition, a double value will have a wider range of exponent values than a float value. The long double value may have more precision and a still wider exponent range, but this is again system dependent. A oating-point constant such as 2.
To specify a float constant or a long double constant, the letter or sufx F or L must be appended to the constant. Thus, 2. The boolean data type, named after the mathematician George Boole, can represent only two values: There are two predened boolean constants, true and false, that can also be used. Boolean objects can be dened using the type specier bool. The following example illustrates the use of boolean objects and constants: Boolean objects are very useful in controlling the ow of a program and agging error conditions.
Recall that all information stored in a computer is represented internally as sequences of binary digits 0 and 1. Each character corresponds to a binary code value. TABLE 2. The character a is represented by the binary value , which is equivalent to the integer value of A total of characters can be represented in the ANSI code. A character constant is enclosed in single quotes, as in A, b, and 3. The type specier for character objects is char.
Once a character is stored in memory as a binary value, the binary value can be interpreted as a character or as an integer, as illustrated in Table 2. However, it is important to note that the binary ANSI representation for a character digit is not equal to the binary representation for an integer digit. From Table 2. Thus, performing a computation with the character representation of a digit does not yield the same result as performing the computation with the integer representation of the digit.
The following program illustrates this feature of character data: The output from this program is value of ch: A literal string constant is a sequence of characters enclosed within double quotes, as in sensor, F18, or Jane Doe. String variables can be represented as C-style strings using arrays of type char, or as string objects using the string class.
Both representations will be discussed in detail in Chapter 7. In this section, we give a brief introduction to the string class. To use the string class, a program must include the following preprocessor directive: The string object salutation has a size, or length, of ve.
The string object name has a size of eight. The size of a string object may change during execution. A symbolic constant is dened using the const modier. Engineering constants such as or the acceleration of gravity are good candidates for symbolic constants. For example, consider the following declaration statement to assign a value to the symbolic constant PI: The acos function, when evaluated at 1, will return an approximation for that includes 15 digits of precision.
Statements that need to use the value of would then use the symbolic constant PI as illustrated in this statement: Symbolic constants are usually dened with uppercase identiers as in PI instead of pi to indicate that they are symbolic constants, and, of course, the identiers should be selected so that they are easy to remember. Once an identier has been declared and initialized using the const modier, its value cannot be changed within the program.
Give the declaration statements required to dene symbolic constants for these constants: Built-in data types do not require any include directives. A well-designed programmer-dened data type requires work to implement, but once dened a new data type can be used as easily as a predened type.
In this section, we will take our rst look at building a programmer-dened data type. As an introduction to building programmer-dened data types, we will dene a new type that represents the concept of a point in a plane. A point in a plane is an object dened by a x, y coordinate. Coordinate values are often oating point values, as opposed to integer values, so we will use the built-in data type double to represent the coordinates in the implementation of our new data type.
The denition of a programmer-dened data type usually consists of two parts: In general, the class declaration and the class implementation are written in separate les. The convention is to name the class declaration le with a. Applications that want to use a programmer-dened type must include the class declaration le in their source code. A class declaration begins with the keyword class followed by an identier that species the name of the new class.
The body of the class declaration is a block of code, terminated with a semicolon. The declaration block includes declaration statements for the data members and declaration statements for the class methods.
The keywords public, private, and protected are used to control access to the data members and class methods. Controlling access to data members and methods is a powerful feature of classes and will be discussed in more detail in later chapters. To illustrate the syntax of a class declaration, we will begin with the declaration of a class named Point. Class methods dene the operations that can be performed on class objects. A constructor is a special method that performs the operation of a type declaration statement.
Recall that we can declare and initialize objects of type double with a type declaration statement as follows: Point p1, p2 1. Class Implementation To complete the denition of our Point class, we need to write the class implementation le. The class implementation le must include a block of code for each of the methods declared in the class declaration. Each block of code must begin with a header that includes the name of the class, followed by the scope resolution operator:: The implementation le for our Point class is given below.
Note that the implementation le includes the compiler directive include "Point. Because Point. Point double x, double y. The parameterized constructor begins with the header Point:: Parameterized constructors provide parameters for specifying the initial values of the data members. The parameterized Point constructor provides two parameters, x and y, both of type double. This material is protected under all copyright laws, as they currently exist.
No portion of this material may be reproduced, in any form or by any means, without permission in writing from the publisher. Complete Solutions to Practice! Problems Selected Solutions to Modify! Pearson offers special pricing when you package your text with other student resources. If you're interested in creating a cost-saving package for your students, contact your Pearson rep.
Delores M. Her research interests include digital signal processing and biometric signal processing, with an emphasis on identification using iris recognition. She has also written a number of textbooks on computer languages and software engineering.
Etter has held two senior executive positions in the Department of Defense. From June through July , Dr. In that position, she was responsible for Defense Science and Technology strategic planning, budget allocation, and program execution and evaluation for the DoD Science and Technology Program.
Etter is a member of the National Academy of Engineering. Etter has received many national awards and honors. We're sorry! We don't recognize your username or password. Please try again. The work is protected by local and international copyright laws and is provided solely for the use of instructors in teaching their courses and assessing student learning. You have successfully signed out and will be required to sign back in should you need to download more resources. Out of print.
Engineering Problem Solving with C, 4th Edition. Etter, Southern Methodist University. You can check your reasoning as you tackle a problem using our interactive solutions viewer.
Plus, we regularly update and improve textbook solutions based on student ratings and feedback, so you can be sure you're getting the latest information available. How is Chegg Study better than a printed Engineering Problem Solving with C student solution manual from the bookstore? Our interactive player makes it easy to find solutions to Engineering Problem Solving with C problems you're working on - just go to the chapter for your book. Hit a particularly tricky question? Bookmark it to easily review again before an exam.
The best part?