(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
- (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_forward5-Find the solution of the following LP problem using simplex method. Min F =12x, +5x, St. 4x, +2x, 2 80 2.x, + 3x, 2 90 Ans.[0,40]arrow_forwardQ5.A) Work out with the following : 1.(232)10 = ( ? )Excess-3 2.(АВС. 42)16 3 (?)8 3.(1011.11)2 =( ?)10 B) What is the Boolean eq. for the fig. below : C В A Yarrow_forward
- (Practice) Determine the values of the following integer expressions: a.3+46f.202/( 6+3)b.34/6+6g.( 202)/6+3c.23/128/4h.( 202)/( 6+3)d.10( 1+73)i.5020e.202/6+3j.( 10+3)4arrow_forwardAnalyze the running time (i.e. T(n)) of these functions. You should be able to find some simple function f(n) such that T(n) O(f(n)). You should show your work and rigorously justify your an- 1. swer.arrow_forwardQuestion The refractive index of Sodium Chloride is 1.54. Make a function by which user can Find the critical angle of diamond by taking Air as a rare medium (Refractive index of Air is 1). Note: (User Take different incident Angles as a Input)arrow_forward
- H.W:- Used Cramer's Rule to find the value of the variables in the following equations 3x1 + 2x2 - x3 = 4, (1) x1 + x2 - 5x3 = -3, (2) -2x1 - x2 + 4x3 = 0. (3)arrow_forwardx+25 - Calculate the second derivative of f (x) 4.8 and h-0.4, at X - using centered divided difference and Richardson extrapolation. hi f"(x) using h) f"(x) using h2 f"(x) using Richardson extrapolationarrow_forward(discrete Math)arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr