(a)
The following program will determine the value of int(a) where value of a=10.6.
(a)
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:
(b)
The following program will determine the value of int(b) where the value of b=13.9.
(b)
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)
The following program will determine the value of int(c) where the value of c=-3.42.
(c)
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:
(d)
The following program will determine the value of int(a+b) where the value of a=10.6 and b=13.9.
(d)
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:
(e)
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)
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:
(f)
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)
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:
(g)
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)
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:
(h)
The following program will determine the value of float(int(a))+b where the value of a=10.6and b=13.9.
(h)
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:
(i)
The following program will determine the value of float(int(a+b)) where the value of a=10.6and b=13.9.
(i)
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:
(j)
The following program will determine the value of abs(a)+abs(b) where the value of a=10.6and b=13.9.
(j)
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:
(j)
The following program will determine the value of sqrt(abs(a-b)) where the value of a=10.6and b=13.9.
(j)
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:
Want to see more full solutions like this?
Chapter 3 Solutions
C++ for Engineers and Scientists
- (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 1arrow_forwardEXAMPLE: The sum of any two even integers is even. Answer: Proof. (direct) Suppose x and y are even integers. By definition of even, let x = 2k and y = 2j for some integers j and k. Then, x+y=2k+2j = 2(k + j) Note that k+j is an integer because it is the sum of integers. Therefore, by definition of even, x + y is even.arrow_forward(MATLAB) Explanation of the process neededarrow_forward
- (2) Use the floor and/or ceiling functions to create formulas for n÷d and n mod darrow_forward7. 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…arrow_forward(32° +2a?) (23 +3x) Indicate the least integer n for which E O(2"). gd +14arrow_forward
- (In Matlab Coding) Pls send me solution in 5 min I will like your answer. Solution must be in typed form.arrow_forwardH.W:- Used Cramer's Rule to find the value of the variables in the following equations: E. x + 3y + 3z = 5 (1) 3x + y 3z = 4 - (2) -3x + 4y + 7z = -7 (3)arrow_forward(Use GNU Octave programming)arrow_forward
- 1. (Floating-Point Arithmetic). For each of the following numbers,(a) determine whether the number is a 4-digit oating-point number (the number of the FPA4);(b) if yes, write the number in the standard form ±0.d1d2d3d4 × 10n, where d1 is a nonzero digit and n ∈ Z;(c) if no, rst chop and then round the number to a number of the FPA4, written in the standard form:(i) − 0.989067000000001; (ii) − 51.8; (iii) − 900.377050000001; (iv) − 5000.0;(v) − 0.023409; (vi) 2036.0; (vii) 0.01814.arrow_forward(Attach Python file only) Using Python, define the function f, and then call it to calculate the value of f(5) given: f(0)%3D8 f9 =2 f(n-1)+14 where n is Natural number A- BI T. 8 13 |! II 123 !!arrow_forwardEXAMPLE: The sum of any two even integers is even. Answer: Proof. (direct) Suppose x and y are even integers. By definition of even, let x = 2k and y = 2j for some integers j and k. Then, x+y=2k+2j = 2(k + j) Note that k+j is an integer because it is the sum of integers. Therefore, by definition of even, x + y is even.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr