C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
bartleby

Videos

Question
Book Icon
Chapter 3.3, Problem 2E

(a)

Program Plan Intro

Program description:

The following program will determine the value of int(a) where value of a=10.6.

(a)

Expert Solution
Check Mark

Explanation of Solution

Program

//included header file
#include <iostream>
//included namespace
usingnamespacestd;
//main function
intmain()
{
//declare variable a with value 10.6
floata=10.6;
//determine and print the value of int(a)
cout<<int(a);
//exiting from program
return0;
}

Explanation:

In the above code, the value of a is 10.6, which is floating-point type value. The int(a) will typecast the value of a to integer type so that it will print only integer part only.

Sample Output:

  C++ for Engineers and Scientists, Chapter 3.3, Problem 2E , additional homework tip  1

(b)

Program Plan Intro

The following program will determine the value of int(b) where the value of b=13.9.

(b)

Expert Solution
Check Mark

Explanation of Solution

Program

//included header file
#include <iostream>
//included namespace
usingnamespacestd;
//main function
intmain()
{
//declare variable b with value 13.9
floatb=13.9;
//determine and print the value of int(b)
cout<<int(b);
//exiting from program
return0;
}

Explanation:

In the above code, the value of b is 13.9, which is floating-point type value. The int(b) will typecast the value of a to integer type so that it will print only integer part only.

Sample Output:

  C++ for Engineers and Scientists, Chapter 3.3, Problem 2E , additional homework tip  2

(c)

Program Plan Intro

The following program will determine the value of int(c) where the value of c=-3.42.

(c)

Expert Solution
Check Mark

Explanation of Solution

Program

//included header file
#include <iostream>
//included namespace
usingnamespacestd;
//main function
intmain()
{
//declare variable c with value -3.42
floatc=-3.42;
//determine and print the value of int(c)
cout<<int(c);
//exiting from program
return0;
}

Explanation:

In the above code, the value of c is -3.42, which is floating-point type value. The int(c) will typecast the value of a to integer type so that it will print only integer part only.

Sample Output:

  C++ for Engineers and Scientists, Chapter 3.3, Problem 2E , additional homework tip  3

(d)

Program Plan Intro

The following program will determine the value of int(a+b) where the value of a=10.6 and b=13.9.

(d)

Expert Solution
Check Mark

Explanation of Solution

Program

//included header file
#include <iostream>
//included namespace
usingnamespacestd;
//main function
intmain()
{
//declare variable a with value 10.6 and bwith value 13.9
float a=10.6, b=13.9;
//determine and print the value of int(a+b)
cout<<int(a+b);
//exiting from program
return0;
}

Explanation:

In the above code, the value of a is 10.6 and b is 13.9, which is floating-point type value. The int(a+b) will first add the value a and b then typecast the value of its result to an integer type and then print the value using cout statement.

Sample Output:

  C++ for Engineers and Scientists, Chapter 3.3, Problem 2E , additional homework tip  4

(e)

Program Plan Intro

The following program will determine the value of int(a+b) where the value of a=10.6, b=13.9 and c=-3.42.

(e)

Expert Solution
Check Mark

Explanation of Solution

Program

//included header file
#include <iostream>
//included namespace
usingnamespacestd;
//main function
intmain()
{
//declare variable a with value 10.6, b with 13.9 and c with -3.42
float a=10.6, b=13.9, c=-3.42;
//determine and print the value of int(a)+b+c
cout<<int(a)+b+c;
//exiting from program
return0;
}

Explanation:

In the above code, the value of a is 10.6, b is 13.9, and c is -3.42, which is floating-point type value. The int(a)+b+c will typecast the value of a to an integer type and then add and print the integer value of a, b and c.

Sample Output:

  C++ for Engineers and Scientists, Chapter 3.3, Problem 2E , additional homework tip  5

(f)

Program Plan Intro

The following program will determine the value of int(a+b)+c where the value of a=10.6, b=13.9 and c=-3.42.

(f)

Expert Solution
Check Mark

Explanation of Solution

Program

//included header file
#include <iostream>
//included namespace
usingnamespacestd;
//main function
intmain()
{
//declare variable a with value 10.6, b with 13.9 and c with -3.42
float a=10.6, b=13.9, c=-3.42;
//determine and print the value of int(a+b)+c
cout<<int(a+b)+c;
//exiting from program
return0;
}

Explanation:

In the above code, the value of a is 10.6, b is 13.9, and c is -3.42, which is floating-point type value. The int(a+b) will first add the value a and b then typecast the value of its result to an integer type and then add the value of c to it.

Sample Output:

  C++ for Engineers and Scientists, Chapter 3.3, Problem 2E , additional homework tip  6

(g)

Program Plan Intro

The following program will determine the value of int(a+b+c) where the value of a=10.6, b=13.9 and c=-3.42.

(g)

Expert Solution
Check Mark

Explanation of Solution

Program

//included header file
#include <iostream>
//included namespace
usingnamespacestd;
//main function
intmain()
{
//declare variable a with value 10.6, b with 13.9 and c with -3.42
float a=10.6, b=13.9, c=-3.42;
//determine and print the value of int(a+b+c)
cout<<int(a+b+c);
//exiting from program
return0;
}

Explanation:

In the above code, the value of a is 10.6, b is 13.9, and c is -3.42, which is floating-point type value. The int(a+b+c) will first add the value of a, b and c then typecast the value of its result to an integer type and print the value using cout statement.

Sample Output:

  C++ for Engineers and Scientists, Chapter 3.3, Problem 2E , additional homework tip  7

(h)

Program Plan Intro

The following program will determine the value of float(int(a))+b where the value of a=10.6and b=13.9.

(h)

Expert Solution
Check Mark

Explanation of Solution

Program

//included header file
#include <iostream>
//included namespace
usingnamespacestd;
//main function
intmain()
{
//declare variable a with value 10.6 and b with 13.9
float a=10.6, b=13.9, c=-3.42;
//determine and print the value of float(int(a))+b 
cout<<float(int(a))+b ;
//exiting from program
return0;
}

Explanation:

In the above code, the value of a is 10.6and b is 13.9, which is floating-point type value. The float(int(a))+bwill first typecast the value of a to an integer type and then typecast this integer value to float and then add value b to it and print the value using cout statement.

Sample Output:

  C++ for Engineers and Scientists, Chapter 3.3, Problem 2E , additional homework tip  8

(i)

Program Plan Intro

The following program will determine the value of float(int(a+b)) where the value of a=10.6and b=13.9.

(i)

Expert Solution
Check Mark

Explanation of Solution

Program

//included header file
#include <iostream>
//included namespace
usingnamespacestd;
//main function
intmain()
{
//declare variable a with value 10.6 and b with 13.9
float a=10.6, b=13.9, c=-3.42;
//determine and print the value of float(int(a+b))  
cout<<float(int(a+b))  ;
//exiting from program
return0;
}

Explanation:

In the above code, the value of a is 10.6and b is 13.9, which is floating-point type value. The float(int(a+b))will first add the value of a+b and then typecast the value of its result to an integer type and then typecast this integer value to float and print the value using cout statement.

Sample Output:

  C++ for Engineers and Scientists, Chapter 3.3, Problem 2E , additional homework tip  9

(j)

Program Plan Intro

The following program will determine the value of abs(a)+abs(b) where the value of a=10.6and b=13.9.

(j)

Expert Solution
Check Mark

Explanation of Solution

Program

//included header file
#include <iostream>
#include <cmath>
//included namespace
usingnamespacestd;
//main function
intmain()
{
//declare variable a with value 10.6 and b with 13.9
float a=10.6, b=13.9, c=-3.42;
//determine and print the value of abs(a)+abs(b) 
cout<<abs(a)+abs(b)   ;
//exiting from program
return0;
}

Explanation:

In the above code, the value of a is 10.6and b is 13.9, which is floating-point type value. The abs(a) and abs(b)function are used to get the absolute value of a and b then add this absolute value with each other and print the value using cout statement.

Sample Output:

  C++ for Engineers and Scientists, Chapter 3.3, Problem 2E , additional homework tip  10

(j)

Program Plan Intro

The following program will determine the value of sqrt(abs(a-b)) where the value of a=10.6and b=13.9.

(j)

Expert Solution
Check Mark

Explanation of Solution

Program

//included header file
#include <iostream>
#include <cmath>
//included namespace
usingnamespacestd;
//main function
intmain()
{
//declare variable a with value 10.6 and b with 13.9
float a=10.6, b=13.9, c=-3.42;
//determine and print the value of sqrt(abs(a-b)) 
cout<<sqrt(abs(a-b));
//exiting from program
return0;
}

Explanation:

In the above code, the value of a is 10.6and b is 13.9, which is floating-point type value. The abs(a-b)function will determine the absolute value of a-b then the sqrt()function will determine the square root value of this resultand print the value using cout statement.

Sample Output:

  C++ for Engineers and Scientists, Chapter 3.3, Problem 2E , additional homework tip  11

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
(numerical analysis matlab) 3) It is requested to solve the X₁, X2,X3 unknowns in the given equation system by using Gauss-Jordan method. Find the result by writing a program. X1 X2 + x3 = 0 X2 + x3 = 0 3x12x2 + 3x3 = 0 -X1 X3 = 0 -
(b) Write down a Boolean formula for the function f, given the following truth table. [You may use any reasonable notation, but you must be consistent.] a b с f(a,b,c) 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 0 1 1 1 1
7. To obtain the are sine of 0.5 degree, use Math.asin(0.5) Math.asin(Math.toDegrees(0.5)) Math.asin(Math.toRadians(0.5)) Math.sin(0.5) a. b. с. d. 8. What is the value of the following expression? true || true && false true false а. b. 9. What is y displayed in the following code? public class Testl { public static void main(String[] args) { int x = 1; int y = x = x + 1; System.out.println("y is " + y); } } a. y is 0. b. y is 1 because x is assigned to y first. c. y is 2 because x + 1 is assigned to x and then x is assigned to y. d. The program has a compile error since x is redeclared in the statement int y = x = x +1 10. Analyze the following program fragment: int x; double d = 1.5; switch (d) { case 1.0: x = 1; case 1.5: x = 2; case 2.0: x = 3; Which of these is correct about the above code? The program has a compile error because the required break statement is missing in the switch statement. The program has a compile error because the required default case is missing in the…

Chapter 3 Solutions

C++ for Engineers and Scientists

Ch. 3.1 - (Debug) Determine and correct the errors in the...Ch. 3.1 - Prob. 12ECh. 3.1 - Prob. 13ECh. 3.1 - (General math) The area of an ellipse (see Figure...Ch. 3.1 - Prob. 15ECh. 3.2 - Prob. 1ECh. 3.2 - Prob. 2ECh. 3.2 - (Practice) Write a C++ program that displays the...Ch. 3.2 - Prob. 4ECh. 3.2 - Prob. 5ECh. 3.2 - Prob. 6ECh. 3.2 - Prob. 7ECh. 3.2 - Prob. 8ECh. 3.2 - (Electrical eng.) The combined resistance of three...Ch. 3.2 - Prob. 10ECh. 3.2 - Prob. 11ECh. 3.2 - (Civil eng.) Write a C++ program to calculate and...Ch. 3.3 - Prob. 1ECh. 3.3 - Prob. 2ECh. 3.3 - (Practice) Write C++ statements for the following:...Ch. 3.3 - Prob. 4ECh. 3.3 - (General math) Write, compile, and run a C++...Ch. 3.3 - (General math) If a 20-foot ladder is placed on...Ch. 3.3 - (Physics) The maximum height reached by a ball...Ch. 3.3 - (Transportation) Road construction requires...Ch. 3.3 - Prob. 9ECh. 3.3 - Prob. 10ECh. 3.3 - Prob. 11ECh. 3.3 - Prob. 12ECh. 3.4 - Prob. 1ECh. 3.4 - (Practice) a. Write a C++ program that first...Ch. 3.4 - Prob. 3ECh. 3.4 - Prob. 4ECh. 3.4 - Prob. 5ECh. 3.4 - Prob. 6ECh. 3.4 - (General math) a. Write, compile, and run a C++...Ch. 3.4 - Prob. 8ECh. 3.4 - Prob. 9ECh. 3.4 - (Electrical eng.) For the series circuit shown in...Ch. 3.4 - Prob. 11ECh. 3.4 - Prob. 12ECh. 3.4 - Prob. 13ECh. 3.5 - Prob. 1ECh. 3.5 - Prob. 2ECh. 3.5 - Prob. 3ECh. 3.5 - Prob. 4ECh. 3.5 - Prob. 5ECh. 3.6 - Prob. 1ECh. 3.6 - (General math) The value of p can be approximated...Ch. 3.6 - Prob. 3ECh. 3.6 - (General math) The volume of oil stored in an...Ch. 3.6 - Prob. 5ECh. 3.6 - (General math) The perimeter, approximate surface...Ch. 3.6 - Prob. 7ECh. 3.6 - Prob. 8ECh. 3.6 - Prob. 9ECh. 3 - (General math) a. Write a C++ program to calculate...Ch. 3 - General math) a. Write a C++ program to calculate...Ch. 3 - (General math) Modify the program written for...Ch. 3 - (Biology) The number of bacteria, B, in a culture...Ch. 3 - Prob. 5PPCh. 3 - (Heat transfer) The formula developed in Exercise...Ch. 3 - Prob. 7PPCh. 3 - (Electrical eng.) a. The voltage gain of an...Ch. 3 - (Electrical eng.) a. Write, compile, and run a C++...Ch. 3 - (Electrical eng.) The amplification of electronic...Ch. 3 - (Acoustics) The loudness of a sound is measured in...Ch. 3 - (General math) a. A balance has the following...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Boolean Algebra - Digital Logic and Logic Families - Industrial Electronics; Author: Ekeeda;https://www.youtube.com/watch?v=u7XnJos-_Hs;License: Standard YouTube License, CC-BY
Boolean Algebra 1 – The Laws of Boolean Algebra; Author: Computer Science;https://www.youtube.com/watch?v=EPJf4owqwdA;License: Standard Youtube License